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

40 lines
1.0 KiB
PHP
Raw Normal View History

2016-05-01 13:31:10 +02:00
<?php namespace App\Http\Requests;
2016-05-01 21:30:39 +02:00
class UpdateInvoiceRequest extends InvoiceRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
2016-05-01 21:30:39 +02:00
return $this->user()->can('edit', $this->entity());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
2016-05-01 21:30:39 +02:00
$invoiceId = $this->entity()->id;
$rules = [
2016-05-01 21:30:39 +02:00
'client.contacts' => 'valid_contacts',
2016-02-09 22:51:08 +01:00
'invoice_items' => 'valid_invoice_items',
2016-05-01 21:30:39 +02:00
'invoice_number' => 'required|unique:invoices,invoice_number,' . $invoiceId . ',id,account_id,' . $this->user()->account_id,
'discount' => 'positive',
];
2016-05-01 21:30:39 +02:00
/* There's a problem parsing the dates
if (Request::get('is_recurring') && Request::get('start_date') && Request::get('end_date')) {
$rules['end_date'] = 'after' . Request::get('start_date');
}
*/
return $rules;
}
}