2019-05-03 00:29:04 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
namespace App\Http\Requests\RecurringInvoice;
|
|
|
|
|
|
|
|
use App\Http\Requests\Request;
|
|
|
|
use App\Models\RecurringInvoice;
|
2020-02-15 10:06:30 +01:00
|
|
|
use App\Utils\Traits\CleanLineItems;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
class StoreRecurringInvoiceRequest extends Request
|
|
|
|
{
|
2020-02-15 10:06:30 +01:00
|
|
|
use MakesHash;
|
|
|
|
use CleanLineItems;
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function authorize() : bool
|
|
|
|
{
|
|
|
|
return auth()->user()->can('create', RecurringInvoice::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
2020-02-15 10:06:30 +01:00
|
|
|
'client_id' => 'required|exists:clients,id',
|
2019-05-03 00:29:04 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 12:23:09 +01:00
|
|
|
protected function prepareForValidation()
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
2020-02-15 10:06:30 +01:00
|
|
|
$input = $this->all();
|
|
|
|
|
2020-02-17 10:37:44 +01:00
|
|
|
if($input['client_id'])
|
|
|
|
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
|
|
|
|
2020-02-15 10:06:30 +01:00
|
|
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
|
|
|
//$input['line_items'] = json_encode($input['line_items']);
|
|
|
|
$this->replace($input);
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function messages()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|