/** * Updates entity restrictions from a request * @param $request * @param Entity $entity */ public function updateEntityPermissionsFromRequest($request, Entity $entity) { $entity->restricted = $request->has('restricted') && $request->get('restricted') === 'true'; $entity->permissions()->delete(); if ($request->has('restrictions')) { foreach ($request->get('restrictions') as $roleId => $restrictions) { foreach ($restrictions as $action => $value) { $entity->permissions()->create(['role_id' => $roleId, 'action' => strtolower($action)]); } } } $entity->save(); $this->permissionService->buildJointPermissionsForEntity($entity); }
/** * Alias method to update the book jointPermissions in the PermissionService. * @param Collection $collection collection on entities */ public function buildJointPermissions(Collection $collection) { $this->permissionService->buildJointPermissionsForEntities($collection); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->permissionService->buildJointPermissions(); }