1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 23:22:52 +01:00
invoiceninja/app/Http/Requests/TicketRequest.php
2019-01-30 22:25:07 +11:00

35 lines
754 B
PHP

<?php
namespace App\Http\Requests;
class TicketRequest extends EntityRequest
{
protected $entityType = ENTITY_TICKET;
public function entity()
{
$ticket = parent::entity();
// eager load the documents
if ($ticket && method_exists($ticket, 'documents') && ! $ticket->relationLoaded('documents'))
$ticket->load('documents', 'relations');
return $ticket;
}
public function authorize()
{
if(request()->is('tickets/create*') && $this->user()->can('createEntity', ENTITY_TICKET))
return true;
elseif (request()->is('tickets/*/edit') && $this->user()->can('view', $this->entity()))
return true;
else
return false;
}
}