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