<?php namespace Bixo\App\Policies; use Illuminate\Foundation\Auth\User as Authenticatable; use Bixo\App\Models\App; class AppPolicy { use AppWorkflow; /** * Determine if the given user can view the app. * * @param Authenticatable $user * @param App $app * * @return bool */ public function view(Authenticatable $user, App $app) { if ($authUser->canDo('app.app.view') && $authUser->isAdmin() || $user->isClient()) { return true; } return $app->is_owner; } /** * Determine if the given user can create a app. * * @param Authenticatable $user * * @return bool */ public function create(Authenticatable $user) { return $authUser->canDo('app.app.create'); } /** * Determine if the given user can update the given app. * * @param Authenticatable $user * @param App $app * * @return bool */ public function update(Authenticatable $user, App $app) { if ($user->canDo('app.app.edit') && $user->isAdmin()) { return true; } return $app->is_owner; } /** * Determine if the given user can delete the given app. * * @param Authenticatable $user * * @return bool */ public function destroy(Authenticatable $user, App $app) { return $app->is_owner; } /** * 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; } } }