mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +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;
|
|
}
|
|
} |