1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Http/Requests/UpdateInvoiceAPIRequest.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Http\Requests;
2016-05-01 21:30:39 +02:00
2017-01-03 20:48:40 +01:00
use App\Models\Client;
2016-05-01 21:30:39 +02:00
class UpdateInvoiceAPIRequest extends InvoiceRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
2017-07-12 22:56:31 +02:00
return $this->entity() && $this->user()->can('edit', $this->entity());
2016-05-01 21:30:39 +02:00
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
2017-07-12 22:56:31 +02:00
if (! $this->entity()) {
return [];
}
2016-05-01 21:30:39 +02:00
if ($this->action == ACTION_ARCHIVE) {
return [];
}
$invoiceId = $this->entity()->id;
$rules = [
2018-04-29 16:27:55 +02:00
'invoice_items' => 'valid_invoice_items',
2016-05-01 21:30:39 +02:00
'invoice_number' => 'unique:invoices,invoice_number,' . $invoiceId . ',id,account_id,' . $this->user()->account_id,
'discount' => 'positive',
2016-08-15 21:57:05 +02:00
//'invoice_date' => 'date',
//'due_date' => 'date',
//'start_date' => 'date',
//'end_date' => 'date',
2016-05-01 21:30:39 +02:00
];
return $rules;
}
}