changes
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\PageReferenceLists;
|
||||
|
||||
use App\Containers\Widget\Models\PageReferenceList;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreatePageReferenceListAction
|
||||
{
|
||||
public function run(array $data): PageReferenceList
|
||||
{
|
||||
$data['slug'] = $data['slug'] ?? Str::slug($data['title']);
|
||||
$data['is_active'] = $data['is_active'] ?? true;
|
||||
$data['content'] = $data['content'] ?? [];
|
||||
|
||||
return PageReferenceList::create($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\PageReferenceLists;
|
||||
|
||||
use App\Containers\Widget\Models\PageReferenceList;
|
||||
|
||||
class DeletePageReferenceListAction
|
||||
{
|
||||
public function run(PageReferenceList $list): bool
|
||||
{
|
||||
return $list->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\PageReferenceLists;
|
||||
|
||||
use App\Containers\Widget\Models\PageReferenceList;
|
||||
|
||||
class ListPageReferenceListsAction
|
||||
{
|
||||
public function run(array $filters = []): array
|
||||
{
|
||||
$query = PageReferenceList::query();
|
||||
|
||||
if (!empty($filters['search'])) {
|
||||
$query->where('title', 'like', '%' . $filters['search'] . '%');
|
||||
}
|
||||
|
||||
if (isset($filters['is_active']) && $filters['is_active'] !== '') {
|
||||
$query->where('is_active', (bool) $filters['is_active']);
|
||||
}
|
||||
|
||||
$lists = $query->orderByDesc('created_at')->paginate(20)->withQueryString();
|
||||
|
||||
return [
|
||||
'lists' => $lists,
|
||||
'filters' => $filters,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\Actions\PageReferenceLists;
|
||||
|
||||
use App\Containers\Widget\Models\PageReferenceList;
|
||||
|
||||
class UpdatePageReferenceListAction
|
||||
{
|
||||
public function run(PageReferenceList $list, array $data): PageReferenceList
|
||||
{
|
||||
$list->update($data);
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user