first change
This commit is contained in:
56
Modules/Template/app/Repositories/TemplateRepository.php
Normal file
56
Modules/Template/app/Repositories/TemplateRepository.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Template\Repositories;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Template\Models\Template;
|
||||
|
||||
class TemplateRepository implements TemplateInterface
|
||||
{
|
||||
public function findAll($request, callable $query = null, bool $paginate = false, int $limit = 10)
|
||||
{
|
||||
return Template::get();
|
||||
}
|
||||
|
||||
public function findById($id, callable $query = null)
|
||||
{
|
||||
return Template::findOrFail($id);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
return Template::where('id', $id)->delete();
|
||||
}
|
||||
|
||||
public function create(array $data)
|
||||
{
|
||||
return Template::create($data);
|
||||
}
|
||||
|
||||
public function update($id, array $newDetails)
|
||||
{
|
||||
return Template::where('id', $id)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(callable $query = null)
|
||||
{
|
||||
return Template::where(['status' => 11])
|
||||
->select('id', 'title', 'alias', 'type')
|
||||
->get()
|
||||
->groupBy('type')
|
||||
->mapWithKeys(function ($templates, $type) {
|
||||
return [
|
||||
$type => $templates->mapWithKeys(function ($template) {
|
||||
return [$template->id => $template->title];
|
||||
}),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function where($filter)
|
||||
{
|
||||
return Template::where($filter);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user