update deploy
This commit is contained in:
22
app/Actions/Announcement/CreateAnnouncementAction.php
Normal file
22
app/Actions/Announcement/CreateAnnouncementAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Announcement;
|
||||
|
||||
use App\DTOs\AnnouncementData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Announcement;
|
||||
use App\Repositories\Contracts\AnnouncementRepositoryInterface;
|
||||
|
||||
final class CreateAnnouncementAction
|
||||
{
|
||||
public function __construct(private AnnouncementRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(AnnouncementData $data): Announcement
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Announcement::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Announcement/DeleteAnnouncementAction.php
Normal file
21
app/Actions/Announcement/DeleteAnnouncementAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Announcement;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Announcement;
|
||||
use App\Repositories\Contracts\AnnouncementRepositoryInterface;
|
||||
|
||||
final class DeleteAnnouncementAction
|
||||
{
|
||||
public function __construct(private AnnouncementRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Announcement $announcement): bool
|
||||
{
|
||||
$this->repository->delete($announcement);
|
||||
|
||||
ModelChanged::dispatch(Announcement::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Announcement/UpdateAnnouncementAction.php
Normal file
22
app/Actions/Announcement/UpdateAnnouncementAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Announcement;
|
||||
|
||||
use App\DTOs\AnnouncementData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Announcement;
|
||||
use App\Repositories\Contracts\AnnouncementRepositoryInterface;
|
||||
|
||||
final class UpdateAnnouncementAction
|
||||
{
|
||||
public function __construct(private AnnouncementRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Announcement $announcement, AnnouncementData $data): Announcement
|
||||
{
|
||||
$result = $this->repository->update($announcement, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Announcement::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
23
app/Actions/Category/CreateCategoryAction.php
Normal file
23
app/Actions/Category/CreateCategoryAction.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Category;
|
||||
|
||||
use App\DTOs\CategoryData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Category;
|
||||
use App\Repositories\Contracts\CategoryRepositoryInterface;
|
||||
|
||||
class CreateCategoryAction
|
||||
{
|
||||
public function __construct(private CategoryRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(CategoryData $data): Category
|
||||
{
|
||||
/** @var Category */
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Category::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Category/DeleteCategoryAction.php
Normal file
21
app/Actions/Category/DeleteCategoryAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Category;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Category;
|
||||
use App\Repositories\Contracts\CategoryRepositoryInterface;
|
||||
|
||||
class DeleteCategoryAction
|
||||
{
|
||||
public function __construct(private CategoryRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Category $category): bool
|
||||
{
|
||||
$this->repository->delete($category);
|
||||
|
||||
ModelChanged::dispatch(Category::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
23
app/Actions/Category/UpdateCategoryAction.php
Normal file
23
app/Actions/Category/UpdateCategoryAction.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Category;
|
||||
|
||||
use App\DTOs\CategoryData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Category;
|
||||
use App\Repositories\Contracts\CategoryRepositoryInterface;
|
||||
|
||||
class UpdateCategoryAction
|
||||
{
|
||||
public function __construct(private CategoryRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Category $category, CategoryData $data): Category
|
||||
{
|
||||
/** @var Category */
|
||||
$result = $this->repository->update($category, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Category::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Comment/CreateCommentAction.php
Normal file
22
app/Actions/Comment/CreateCommentAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Comment;
|
||||
|
||||
use App\DTOs\CommentData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Comment;
|
||||
use App\Repositories\Contracts\CommentRepositoryInterface;
|
||||
|
||||
final class CreateCommentAction
|
||||
{
|
||||
public function __construct(private CommentRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(CommentData $data): Comment
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Comment::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Comment/DeleteCommentAction.php
Normal file
21
app/Actions/Comment/DeleteCommentAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Comment;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Comment;
|
||||
use App\Repositories\Contracts\CommentRepositoryInterface;
|
||||
|
||||
final class DeleteCommentAction
|
||||
{
|
||||
public function __construct(private CommentRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Comment $comment): bool
|
||||
{
|
||||
$this->repository->delete($comment);
|
||||
|
||||
ModelChanged::dispatch(Comment::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
24
app/Actions/Comment/UpdateCommentAction.php
Normal file
24
app/Actions/Comment/UpdateCommentAction.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Comment;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Comment;
|
||||
use App\Repositories\Contracts\CommentRepositoryInterface;
|
||||
|
||||
final class UpdateCommentAction
|
||||
{
|
||||
public function __construct(private CommentRepositoryInterface $repository) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function execute(Comment $comment, array $data): Comment
|
||||
{
|
||||
$result = $this->repository->update($comment, $data);
|
||||
|
||||
ModelChanged::dispatch(Comment::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
23
app/Actions/Course/CreateCourseAction.php
Normal file
23
app/Actions/Course/CreateCourseAction.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Course;
|
||||
|
||||
use App\DTOs\CourseData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Course;
|
||||
use App\Repositories\Contracts\CourseRepositoryInterface;
|
||||
|
||||
class CreateCourseAction
|
||||
{
|
||||
public function __construct(private CourseRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(CourseData $data): Course
|
||||
{
|
||||
/** @var Course */
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Course::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Course/DeleteCourseAction.php
Normal file
21
app/Actions/Course/DeleteCourseAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Course;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Course;
|
||||
use App\Repositories\Contracts\CourseRepositoryInterface;
|
||||
|
||||
class DeleteCourseAction
|
||||
{
|
||||
public function __construct(private CourseRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Course $course): bool
|
||||
{
|
||||
$this->repository->delete($course);
|
||||
|
||||
ModelChanged::dispatch(Course::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
23
app/Actions/Course/UpdateCourseAction.php
Normal file
23
app/Actions/Course/UpdateCourseAction.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Course;
|
||||
|
||||
use App\DTOs\CourseData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Course;
|
||||
use App\Repositories\Contracts\CourseRepositoryInterface;
|
||||
|
||||
class UpdateCourseAction
|
||||
{
|
||||
public function __construct(private CourseRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Course $course, CourseData $data): Course
|
||||
{
|
||||
/** @var Course */
|
||||
$result = $this->repository->update($course, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Course::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Faq/CreateFaqAction.php
Normal file
22
app/Actions/Faq/CreateFaqAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Faq;
|
||||
|
||||
use App\DTOs\FaqData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Faq;
|
||||
use App\Repositories\Contracts\FaqRepositoryInterface;
|
||||
|
||||
final class CreateFaqAction
|
||||
{
|
||||
public function __construct(private FaqRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(FaqData $data): Faq
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Faq::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Faq/DeleteFaqAction.php
Normal file
21
app/Actions/Faq/DeleteFaqAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Faq;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Faq;
|
||||
use App\Repositories\Contracts\FaqRepositoryInterface;
|
||||
|
||||
final class DeleteFaqAction
|
||||
{
|
||||
public function __construct(private FaqRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Faq $faq): bool
|
||||
{
|
||||
$this->repository->delete($faq);
|
||||
|
||||
ModelChanged::dispatch(Faq::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Faq/UpdateFaqAction.php
Normal file
22
app/Actions/Faq/UpdateFaqAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Faq;
|
||||
|
||||
use App\DTOs\FaqData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Faq;
|
||||
use App\Repositories\Contracts\FaqRepositoryInterface;
|
||||
|
||||
final class UpdateFaqAction
|
||||
{
|
||||
public function __construct(private FaqRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Faq $faq, FaqData $data): Faq
|
||||
{
|
||||
$result = $this->repository->update($faq, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Faq::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/GuideCard/CreateGuideCardAction.php
Normal file
22
app/Actions/GuideCard/CreateGuideCardAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\GuideCard;
|
||||
|
||||
use App\DTOs\GuideCardData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\GuideCard;
|
||||
use App\Repositories\Contracts\GuideCardRepositoryInterface;
|
||||
|
||||
final class CreateGuideCardAction
|
||||
{
|
||||
public function __construct(private GuideCardRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(GuideCardData $data): GuideCard
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(GuideCard::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/GuideCard/DeleteGuideCardAction.php
Normal file
21
app/Actions/GuideCard/DeleteGuideCardAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\GuideCard;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\GuideCard;
|
||||
use App\Repositories\Contracts\GuideCardRepositoryInterface;
|
||||
|
||||
final class DeleteGuideCardAction
|
||||
{
|
||||
public function __construct(private GuideCardRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(GuideCard $guideCard): bool
|
||||
{
|
||||
$this->repository->delete($guideCard);
|
||||
|
||||
ModelChanged::dispatch(GuideCard::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/GuideCard/UpdateGuideCardAction.php
Normal file
22
app/Actions/GuideCard/UpdateGuideCardAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\GuideCard;
|
||||
|
||||
use App\DTOs\GuideCardData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\GuideCard;
|
||||
use App\Repositories\Contracts\GuideCardRepositoryInterface;
|
||||
|
||||
final class UpdateGuideCardAction
|
||||
{
|
||||
public function __construct(private GuideCardRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(GuideCard $guideCard, GuideCardData $data): GuideCard
|
||||
{
|
||||
$result = $this->repository->update($guideCard, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(GuideCard::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/HeroSlide/CreateHeroSlideAction.php
Normal file
22
app/Actions/HeroSlide/CreateHeroSlideAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\HeroSlide;
|
||||
|
||||
use App\DTOs\HeroSlideData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\HeroSlide;
|
||||
use App\Repositories\Contracts\HeroSlideRepositoryInterface;
|
||||
|
||||
final class CreateHeroSlideAction
|
||||
{
|
||||
public function __construct(private HeroSlideRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(HeroSlideData $data): HeroSlide
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(HeroSlide::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/HeroSlide/DeleteHeroSlideAction.php
Normal file
21
app/Actions/HeroSlide/DeleteHeroSlideAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\HeroSlide;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\HeroSlide;
|
||||
use App\Repositories\Contracts\HeroSlideRepositoryInterface;
|
||||
|
||||
final class DeleteHeroSlideAction
|
||||
{
|
||||
public function __construct(private HeroSlideRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(HeroSlide $heroSlide): bool
|
||||
{
|
||||
$this->repository->delete($heroSlide);
|
||||
|
||||
ModelChanged::dispatch(HeroSlide::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/HeroSlide/UpdateHeroSlideAction.php
Normal file
22
app/Actions/HeroSlide/UpdateHeroSlideAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\HeroSlide;
|
||||
|
||||
use App\DTOs\HeroSlideData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\HeroSlide;
|
||||
use App\Repositories\Contracts\HeroSlideRepositoryInterface;
|
||||
|
||||
final class UpdateHeroSlideAction
|
||||
{
|
||||
public function __construct(private HeroSlideRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(HeroSlide $heroSlide, HeroSlideData $data): HeroSlide
|
||||
{
|
||||
$result = $this->repository->update($heroSlide, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(HeroSlide::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Lead/CreateLeadAction.php
Normal file
22
app/Actions/Lead/CreateLeadAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Lead;
|
||||
|
||||
use App\DTOs\LeadData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Lead;
|
||||
use App\Repositories\Contracts\LeadRepositoryInterface;
|
||||
|
||||
final class CreateLeadAction
|
||||
{
|
||||
public function __construct(private LeadRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(LeadData $data): Lead
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Lead::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Lead/DeleteLeadAction.php
Normal file
21
app/Actions/Lead/DeleteLeadAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Lead;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Lead;
|
||||
use App\Repositories\Contracts\LeadRepositoryInterface;
|
||||
|
||||
final class DeleteLeadAction
|
||||
{
|
||||
public function __construct(private LeadRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Lead $lead): bool
|
||||
{
|
||||
$this->repository->delete($lead);
|
||||
|
||||
ModelChanged::dispatch(Lead::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Lead/UpdateLeadAction.php
Normal file
22
app/Actions/Lead/UpdateLeadAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Lead;
|
||||
|
||||
use App\DTOs\LeadData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Lead;
|
||||
use App\Repositories\Contracts\LeadRepositoryInterface;
|
||||
|
||||
final class UpdateLeadAction
|
||||
{
|
||||
public function __construct(private LeadRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Lead $lead, LeadData $data): Lead
|
||||
{
|
||||
$result = $this->repository->update($lead, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Lead::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Menu/CreateMenuAction.php
Normal file
22
app/Actions/Menu/CreateMenuAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Menu;
|
||||
|
||||
use App\DTOs\MenuData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Menu;
|
||||
use App\Repositories\Contracts\MenuRepositoryInterface;
|
||||
|
||||
final class CreateMenuAction
|
||||
{
|
||||
public function __construct(private MenuRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(MenuData $data): Menu
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Menu::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Menu/DeleteMenuAction.php
Normal file
21
app/Actions/Menu/DeleteMenuAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Menu;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Menu;
|
||||
use App\Repositories\Contracts\MenuRepositoryInterface;
|
||||
|
||||
final class DeleteMenuAction
|
||||
{
|
||||
public function __construct(private MenuRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Menu $menu): bool
|
||||
{
|
||||
$this->repository->delete($menu);
|
||||
|
||||
ModelChanged::dispatch(Menu::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Menu/UpdateMenuAction.php
Normal file
22
app/Actions/Menu/UpdateMenuAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Menu;
|
||||
|
||||
use App\DTOs\MenuData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Menu;
|
||||
use App\Repositories\Contracts\MenuRepositoryInterface;
|
||||
|
||||
final class UpdateMenuAction
|
||||
{
|
||||
public function __construct(private MenuRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Menu $menu, MenuData $data): Menu
|
||||
{
|
||||
$result = $this->repository->update($menu, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Menu::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Page/CreatePageAction.php
Normal file
22
app/Actions/Page/CreatePageAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Page;
|
||||
|
||||
use App\DTOs\PageData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Page;
|
||||
use App\Repositories\Contracts\PageRepositoryInterface;
|
||||
|
||||
final class CreatePageAction
|
||||
{
|
||||
public function __construct(private PageRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(PageData $data): Page
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Page::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Page/DeletePageAction.php
Normal file
21
app/Actions/Page/DeletePageAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Page;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Page;
|
||||
use App\Repositories\Contracts\PageRepositoryInterface;
|
||||
|
||||
final class DeletePageAction
|
||||
{
|
||||
public function __construct(private PageRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Page $page): bool
|
||||
{
|
||||
$this->repository->delete($page);
|
||||
|
||||
ModelChanged::dispatch(Page::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Page/UpdatePageAction.php
Normal file
22
app/Actions/Page/UpdatePageAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Page;
|
||||
|
||||
use App\DTOs\PageData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Page;
|
||||
use App\Repositories\Contracts\PageRepositoryInterface;
|
||||
|
||||
final class UpdatePageAction
|
||||
{
|
||||
public function __construct(private PageRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(Page $page, PageData $data): Page
|
||||
{
|
||||
$result = $this->repository->update($page, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(Page::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Schedule/CreateScheduleAction.php
Normal file
22
app/Actions/Schedule/CreateScheduleAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Schedule;
|
||||
|
||||
use App\DTOs\ScheduleData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\CourseSchedule;
|
||||
use App\Repositories\Contracts\ScheduleRepositoryInterface;
|
||||
|
||||
final class CreateScheduleAction
|
||||
{
|
||||
public function __construct(private ScheduleRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(ScheduleData $data): CourseSchedule
|
||||
{
|
||||
$result = $this->repository->create($data->toArray());
|
||||
|
||||
ModelChanged::dispatch(CourseSchedule::class, 'created');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Actions/Schedule/DeleteScheduleAction.php
Normal file
21
app/Actions/Schedule/DeleteScheduleAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Schedule;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\CourseSchedule;
|
||||
use App\Repositories\Contracts\ScheduleRepositoryInterface;
|
||||
|
||||
final class DeleteScheduleAction
|
||||
{
|
||||
public function __construct(private ScheduleRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(CourseSchedule $schedule): bool
|
||||
{
|
||||
$this->repository->delete($schedule);
|
||||
|
||||
ModelChanged::dispatch(CourseSchedule::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Schedule/UpdateScheduleAction.php
Normal file
22
app/Actions/Schedule/UpdateScheduleAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Schedule;
|
||||
|
||||
use App\DTOs\ScheduleData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\CourseSchedule;
|
||||
use App\Repositories\Contracts\ScheduleRepositoryInterface;
|
||||
|
||||
final class UpdateScheduleAction
|
||||
{
|
||||
public function __construct(private ScheduleRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(CourseSchedule $schedule, ScheduleData $data): CourseSchedule
|
||||
{
|
||||
$result = $this->repository->update($schedule, $data->toArray());
|
||||
|
||||
ModelChanged::dispatch(CourseSchedule::class, 'updated');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
22
app/Actions/Setting/UpdateSettingsAction.php
Normal file
22
app/Actions/Setting/UpdateSettingsAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Setting;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\Setting;
|
||||
use App\Repositories\Contracts\SettingRepositoryInterface;
|
||||
|
||||
final class UpdateSettingsAction
|
||||
{
|
||||
public function __construct(private SettingRepositoryInterface $repository) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $settings
|
||||
*/
|
||||
public function execute(array $settings): void
|
||||
{
|
||||
$this->repository->bulkUpdate($settings);
|
||||
|
||||
ModelChanged::dispatch(Setting::class, 'updated');
|
||||
}
|
||||
}
|
||||
29
app/Actions/User/CreateUserAction.php
Normal file
29
app/Actions/User/CreateUserAction.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\User;
|
||||
|
||||
use App\DTOs\UserData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\User;
|
||||
use App\Repositories\Contracts\UserRepositoryInterface;
|
||||
|
||||
class CreateUserAction
|
||||
{
|
||||
public function __construct(private UserRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(UserData $data): User
|
||||
{
|
||||
/** @var User */
|
||||
$user = $this->repository->create($data->toArray());
|
||||
|
||||
if ($data->role) {
|
||||
$user->syncRoles([$data->role]);
|
||||
}
|
||||
|
||||
$user->load('roles');
|
||||
|
||||
ModelChanged::dispatch(User::class, 'created');
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
21
app/Actions/User/DeleteUserAction.php
Normal file
21
app/Actions/User/DeleteUserAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\User;
|
||||
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\User;
|
||||
use App\Repositories\Contracts\UserRepositoryInterface;
|
||||
|
||||
class DeleteUserAction
|
||||
{
|
||||
public function __construct(private UserRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(User $user): bool
|
||||
{
|
||||
$this->repository->delete($user);
|
||||
|
||||
ModelChanged::dispatch(User::class, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
29
app/Actions/User/UpdateUserAction.php
Normal file
29
app/Actions/User/UpdateUserAction.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\User;
|
||||
|
||||
use App\DTOs\UserData;
|
||||
use App\Events\ModelChanged;
|
||||
use App\Models\User;
|
||||
use App\Repositories\Contracts\UserRepositoryInterface;
|
||||
|
||||
class UpdateUserAction
|
||||
{
|
||||
public function __construct(private UserRepositoryInterface $repository) {}
|
||||
|
||||
public function execute(User $user, UserData $data): User
|
||||
{
|
||||
/** @var User */
|
||||
$user = $this->repository->update($user, $data->toArray());
|
||||
|
||||
if ($data->role !== null) {
|
||||
$user->syncRoles([$data->role]);
|
||||
}
|
||||
|
||||
$user->load('roles');
|
||||
|
||||
ModelChanged::dispatch(User::class, 'updated');
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user