1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Don't require new ucwords signature

This commit is contained in:
Joshua Dwire 2016-04-26 20:06:19 -04:00
parent fc0d4d3edd
commit 91efade7f7
2 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,7 @@ use App\Http\Middleware\PermissionsRequired;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Auth;
use Utils;
class BaseController extends Controller
{
@ -34,7 +35,7 @@ class BaseController extends Controller
$this->authorize('create', $this->entity);
}
else{
$className = ucwords($this->entity, '_');
$className = Utils::getEntityName($this->entity);
$object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
$this->authorize('edit', $object);

View File

@ -3,6 +3,7 @@
namespace App\Policies;
use App\Models\User;
use Utils;
use Illuminate\Auth\Access\HandlesAuthorization;
@ -11,7 +12,7 @@ class GenericEntityPolicy
use HandlesAuthorization;
public static function editByOwner($user, $itemType, $ownerUserId) {
$itemType = ucwords($itemType, '_');
$itemType = Utils::getEntityName($itemType);
if (method_exists("App\\Policies\\{$itemType}Policy", 'editByOwner')) {
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'editByOwner'), $user, $ownerUserId);
}
@ -20,7 +21,7 @@ class GenericEntityPolicy
}
public static function viewByOwner($user, $itemType, $ownerUserId) {
$itemType = ucwords($itemType, '_');
$itemType = Utils::getEntityName($itemType);
if (method_exists("App\\Policies\\{$itemType}Policy", 'viewByOwner')) {
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'viewByOwner'), $user, $ownerUserId);
}
@ -29,7 +30,7 @@ class GenericEntityPolicy
}
public static function create($user, $itemType) {
$itemType = ucwords($itemType, '_');
$itemType = Utils::getEntityName($itemType);
if (method_exists("App\\Policies\\{$itemType}Policy", 'create')) {
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'create'), $user);
}