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