mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\User;
|
|
use Utils;
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class GenericEntityPolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
public static function editByOwner($user, $itemType, $ownerUserId) {
|
|
$itemType = Utils::getEntityName($itemType);
|
|
if (method_exists("App\\Policies\\{$itemType}Policy", 'editByOwner')) {
|
|
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'editByOwner'), $user, $ownerUserId);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static function viewByOwner($user, $itemType, $ownerUserId) {
|
|
$itemType = Utils::getEntityName($itemType);
|
|
if (method_exists("App\\Policies\\{$itemType}Policy", 'viewByOwner')) {
|
|
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'viewByOwner'), $user, $ownerUserId);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static function create($user, $itemType) {
|
|
$itemType = Utils::getEntityName($itemType);
|
|
if (method_exists("App\\Policies\\{$itemType}Policy", 'create')) {
|
|
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'create'), $user);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |