24 lines
526 B
PHP
24 lines
526 B
PHP
<?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;
|
|
}
|
|
}
|