44 lines
849 B
PHP
Executable File
44 lines
849 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Jobs\Dashboard\UsefulInfoJob;
|
|
|
|
use App\Models\UsefulInfo;
|
|
use Illuminate\Support\Arr;
|
|
use App\Http\Requests\Dashboard\UsefulInfoRequest\Store as Request;
|
|
|
|
class Store
|
|
{
|
|
protected $attr;
|
|
|
|
/**
|
|
* Store constructor.
|
|
* @param array $attr
|
|
*/
|
|
public function __construct(array $attr = [])
|
|
{
|
|
$this->attr = Arr::only($attr, ['name', 'image', 'position']);
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @param $path
|
|
* @return Store
|
|
*/
|
|
public static function fromRequest(Request $request, $path)
|
|
{
|
|
return new static([
|
|
'name' => $request->getName(),
|
|
'image' => $path,
|
|
'position' => $request->getPosition()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function handle()
|
|
{
|
|
UsefulInfo::create($this->attr);
|
|
}
|
|
}
|