2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs\Auth;
|
|
|
|
|
|
|
|
use App\Abstracts\Job;
|
|
|
|
use App\Models\Auth\Role;
|
|
|
|
|
|
|
|
class UpdateRole extends Job
|
|
|
|
{
|
|
|
|
protected $role;
|
|
|
|
|
|
|
|
protected $request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @param $role
|
|
|
|
* @param $request
|
|
|
|
*/
|
|
|
|
public function __construct($role, $request)
|
|
|
|
{
|
|
|
|
$this->role = $role;
|
|
|
|
$this->request = $this->getRequestInstance($request);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return Role
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2020-06-26 13:40:19 +03:00
|
|
|
\DB::transaction(function () {
|
|
|
|
$this->role->update($this->request->all());
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-06-26 13:40:19 +03:00
|
|
|
if ($this->request->has('permissions')) {
|
|
|
|
$this->role->permissions()->sync($this->request->get('permissions'));
|
|
|
|
}
|
|
|
|
});
|
2019-11-16 10:21:14 +03:00
|
|
|
|
|
|
|
return $this->role;
|
|
|
|
}
|
|
|
|
}
|