2017-09-14 22:21:00 +03:00
|
|
|
<?php
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
namespace App\Http\Requests\Banking;
|
2017-09-14 22:21:00 +03:00
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
use App\Abstracts\Http\FormRequest;
|
2018-08-06 18:41:58 +03:00
|
|
|
use Date;
|
2017-09-14 22:21:00 +03:00
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
class Transaction extends FormRequest
|
2017-09-14 22:21:00 +03:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
2019-11-16 10:21:14 +03:00
|
|
|
$attachment = 'nullable';
|
|
|
|
|
2021-05-14 18:29:24 +03:00
|
|
|
if ($this->files->get('attachment')) {
|
2019-11-16 10:21:14 +03:00
|
|
|
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
|
|
|
|
}
|
|
|
|
|
2017-09-14 22:21:00 +03:00
|
|
|
return [
|
2019-11-16 10:21:14 +03:00
|
|
|
'type' => 'required|string',
|
2017-09-14 22:21:00 +03:00
|
|
|
'account_id' => 'required|integer',
|
2018-09-05 16:43:50 +03:00
|
|
|
'paid_at' => 'required|date_format:Y-m-d H:i:s',
|
2018-08-30 11:58:38 +03:00
|
|
|
'amount' => 'required|amount',
|
2018-06-27 19:28:56 +03:00
|
|
|
'currency_code' => 'required|string|currency',
|
2018-06-24 00:08:32 +03:00
|
|
|
'currency_rate' => 'required',
|
2019-11-16 10:21:14 +03:00
|
|
|
'document_id' => 'nullable|integer',
|
|
|
|
'contact_id' => 'nullable|integer',
|
2017-09-14 22:21:00 +03:00
|
|
|
'category_id' => 'required|integer',
|
|
|
|
'payment_method' => 'required|string',
|
2021-02-10 12:08:16 +03:00
|
|
|
'attachment.*' => $attachment,
|
2017-09-14 22:21:00 +03:00
|
|
|
];
|
|
|
|
}
|
2018-08-06 18:41:58 +03:00
|
|
|
|
|
|
|
public function withValidator($validator)
|
|
|
|
{
|
|
|
|
if ($validator->errors()->count()) {
|
|
|
|
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
|
|
|
|
|
|
|
$this->request->set('paid_at', $paid_at);
|
|
|
|
}
|
|
|
|
}
|
2017-09-14 22:21:00 +03:00
|
|
|
}
|