canDo('client.appclient.view') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.view') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $appclient->user_id; } /** * Determine if the given user can create a appclient. * * @param UserPolicy $user * @param Appclient $appclient * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('client.appclient.create'); } /** * Determine if the given user can update the given appclient. * * @param UserPolicy $user * @param Appclient $appclient * * @return bool */ public function update(UserPolicy $user, Appclient $appclient) { if ($user->canDo('client.appclient.update') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.update') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $appclient->user_id; } /** * Determine if the given user can delete the given appclient. * * @param UserPolicy $user * @param Appclient $appclient * * @return bool */ public function destroy(UserPolicy $user, Appclient $appclient) { if ($user->canDo('client.appclient.delete') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.delete') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $appclient->user_id; } /** * Determine if the given user can verify the given appclient. * * @param UserPolicy $user * @param Appclient $appclient * * @return bool */ public function verify(UserPolicy $user, Appclient $appclient) { if ($user->canDo('client.appclient.verify') && $user->is('admin')) { return true; } if ($user->canDo('client.appclient.verify') && $user->is('manager') && $appclient->user->parent_id == $user->id) { return true; } return false; } /** * Determine if the given user can approve the given appclient. * * @param UserPolicy $user * @param Appclient $appclient * * @return bool */ public function approve(UserPolicy $user, Appclient $appclient) { if ($user->canDo('client.appclient.approve') && $user->is('admin')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $user [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($user, $ability) { if ($user->isSuperUser()) { return true; } } }