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