invoiceninja/app/Http/Requests/CreateDocumentRequest.php

58 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Http\Requests;
2016-05-01 22:30:39 +03:00
use App\Models\Expense;
2017-01-30 21:40:43 +02:00
use App\Models\Invoice;
2016-05-01 22:30:39 +03:00
class CreateDocumentRequest extends DocumentRequest
{
protected $autoload = [
ENTITY_INVOICE,
ENTITY_EXPENSE,
2019-01-30 22:00:26 +11:00
ENTITY_TICKET,
];
2016-05-01 22:30:39 +03:00
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
2019-01-30 22:00:26 +11:00
if(session('contact_key'))
return true;
2019-01-30 22:00:26 +11:00
if (! $this->user()->hasFeature(FEATURE_DOCUMENTS))
return false;
if ($this->invoice && $this->user()->cannot('edit', $this->invoice))
return false;
if ($this->expense && $this->user()->cannot('edit', $this->expense))
return false;
if($this->ticket && $this->user()->cannot('edit', $this->ticket))
return false;
return true;
//return $this->user()->can('create');
2016-05-01 22:30:39 +03:00
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//'file' => 'mimes:jpg'
2016-05-01 22:30:39 +03:00
];
}
}