demo/app/Modules/Category/Tasks/StoreTask.php
2023-03-23 18:50:47 +01:00

42 lines
860 B
PHP

<?php
namespace LaraBB\Category\Tasks;
use LaraBB\Category\Models\Category;
/**
* Class StoreCategoryTask
* @package LaraBB\Category\Tasks
*/
class StoreTask
{
/**
* @var Category
*/
private Category $category;
/**
* StoreCategoryTask constructor.
* @param Category $category
*/
public function __construct(Category $category)
{
$this->category = $category;
}
/**
* @param array $data
* @return Category
*/
public function run(array $data = []): Category
{
$this->category->created_uuid = $data['created_uuid'];
$this->category->updated_uuid = $data['updated_uuid'];
$this->category->title = $data['title'];
$this->category->slug = $data['slug'];
$this->category->save();
return $this->category;
}
}