added pointer interfaces for jobs
This commit is contained in:
@ -3,39 +3,21 @@
|
||||
namespace App\Jobs\Auth;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Auth\Role;
|
||||
|
||||
class CreateRole extends Job
|
||||
class CreateRole extends Job implements ShouldCreate
|
||||
{
|
||||
protected $role;
|
||||
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $this->getRequestInstance($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return Permission
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): Role
|
||||
{
|
||||
\DB::transaction(function () {
|
||||
$this->role = Role::create($this->request->input());
|
||||
$this->model = Role::create($this->request->input());
|
||||
|
||||
if ($this->request->has('permissions')) {
|
||||
$this->role->permissions()->attach($this->request->get('permissions'));
|
||||
$this->model->permissions()->attach($this->request->get('permissions'));
|
||||
}
|
||||
});
|
||||
|
||||
return $this->role;
|
||||
return $this->model;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user