2018-06-23 12:59:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
2020-12-23 22:28:38 +00:00
|
|
|
namespace App\Http\Requests\Document;
|
2018-06-23 12:59:13 +00:00
|
|
|
|
2019-11-16 07:21:14 +00:00
|
|
|
use App\Abstracts\Http\FormRequest;
|
2021-08-08 18:30:08 +00:00
|
|
|
use Illuminate\Support\Str;
|
2018-06-23 12:59:13 +00:00
|
|
|
|
2020-12-23 22:28:38 +00:00
|
|
|
class DocumentItem extends FormRequest
|
2018-06-23 12:59:13 +00:00
|
|
|
{
|
2022-08-29 14:17:38 +00:00
|
|
|
protected $quantity_size = 10;
|
2021-11-08 10:41:15 +00:00
|
|
|
|
2018-06-23 12:59:13 +00:00
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
2021-11-17 14:36:06 +00:00
|
|
|
if (Str::contains($this->request->get('quantity'), ['.', ','])) {
|
2022-08-29 14:17:38 +00:00
|
|
|
$this->quantity_size = 12;
|
2021-08-08 18:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-23 12:59:13 +00:00
|
|
|
return [
|
2020-12-23 22:28:38 +00:00
|
|
|
'type' => 'required|string',
|
|
|
|
|
'document_id' => 'required|integer',
|
2018-06-23 12:59:13 +00:00
|
|
|
'name' => 'required|string',
|
2022-06-09 12:28:26 +00:00
|
|
|
'quantity' => 'required|max:' . $this->quantity_size,
|
2021-05-01 08:38:03 +00:00
|
|
|
'price' => 'required|amount',
|
2018-06-23 12:59:13 +00:00
|
|
|
'total' => 'required',
|
|
|
|
|
'tax' => 'required',
|
|
|
|
|
'tax_id' => 'required',
|
|
|
|
|
];
|
|
|
|
|
}
|
2021-11-08 10:41:15 +00:00
|
|
|
|
|
|
|
|
public function messages()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'quantity.max' => trans('validation.size', ['attribute' => Str::lower(trans('invoices.quantity')), 'size' => $this->quantity_size]),
|
|
|
|
|
];
|
|
|
|
|
}
|
2018-06-23 12:59:13 +00:00
|
|
|
}
|