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