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