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