1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/Controllers/BaseController.php

37 lines
918 B
PHP
Raw Normal View History

2015-03-16 22:45:25 +01:00
<?php namespace App\Http\Controllers;
2016-03-16 00:08:00 +01:00
use App\Http\Middleware\PermissionsRequired;
2016-03-02 14:36:42 +01:00
use Illuminate\Foundation\Bus\DispatchesJobs;
2016-03-16 00:08:00 +01:00
use Auth;
2015-10-28 20:22:07 +01:00
2015-03-16 22:45:25 +01:00
class BaseController extends Controller
{
2016-03-02 14:36:42 +01:00
use DispatchesJobs;
2016-03-16 00:08:00 +01:00
protected $model = 'App\Models\EntityModel';
2015-10-28 20:22:07 +01:00
2015-03-16 22:45:25 +01:00
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if (! is_null($this->layout)) {
$this->layout = View::make($this->layout);
}
}
2016-03-16 00:08:00 +01:00
2016-04-23 17:52:36 +02:00
protected function authorizeUpdate($input){
2016-03-16 00:08:00 +01:00
$creating = empty($input['public_id']) || $input['public_id'] == '-1';
if($creating){
2016-04-23 17:52:36 +02:00
$this->authorize('create', $this->model);
2016-03-16 00:08:00 +01:00
}
else{
$object = call_user_func(array($this->model, 'scope'), $input['public_id'])->firstOrFail();
2016-04-23 17:52:36 +02:00
$this->authorize('edit', $object);
2016-03-16 00:08:00 +01:00
}
2015-03-16 22:45:25 +01:00
}
}