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;
|
2019-12-30 22:59:12 +01:00
|
|
|
use App\Utils\Traits\ChecksEntityStatus;
|
2020-02-15 10:06:30 +01:00
|
|
|
use App\Utils\Traits\CleanLineItems;
|
2019-05-03 00:29:04 +02:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
class UpdateRecurringInvoiceRequest extends Request
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
use ChecksEntityStatus;
|
2020-02-15 10:06:30 +01:00
|
|
|
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('edit', $this->recurring_invoice);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
2019-07-04 06:31:01 +02:00
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
];
|
|
|
|
}
|
2020-02-15 10:06:30 +01:00
|
|
|
|
|
|
|
protected function prepareForValidation()
|
|
|
|
{
|
|
|
|
$input = $this->all();
|
|
|
|
|
2020-06-26 00:29:24 +02:00
|
|
|
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
|
|
|
|
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_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-12-30 22:59:12 +01:00
|
|
|
}
|