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