update deploy
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user