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