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