canDo('infobject.infobject.view') && $user->isAdmin()) { return true; } return $infobject->user_id == user_id() && $infobject->user_type == user_type(); } /** * Determine if the given user can create a infobject. * * @param UserPolicy $user * @param Infobject $infobject * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('infobject.infobject.create'); } /** * Determine if the given user can update the given infobject. * * @param UserPolicy $user * @param Infobject $infobject * * @return bool */ public function update(UserPolicy $user, Infobject $infobject) { if ($user->canDo('infobject.infobject.edit') && $user->isAdmin()) { return true; } return $infobject->user_id == user_id() && $infobject->user_type == user_type(); } /** * Determine if the given user can delete the given infobject. * * @param UserPolicy $user * @param Infobject $infobject * * @return bool */ public function destroy(UserPolicy $user, Infobject $infobject) { return $infobject->user_id == user_id() && $infobject->user_type == user_type(); } /** * Determine if the given user can verify the given infobject. * * @param UserPolicy $user * @param Infobject $infobject * * @return bool */ public function verify(UserPolicy $user, Infobject $infobject) { if ($user->canDo('infobject.infobject.verify')) { return true; } return false; } /** * Determine if the given user can approve the given infobject. * * @param UserPolicy $user * @param Infobject $infobject * * @return bool */ public function approve(UserPolicy $user, Infobject $infobject) { if ($user->canDo('infobject.infobject.approve')) { 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; } } }