2017-09-14 22:21:00 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Income;
|
|
|
|
|
|
|
|
use App\Http\Requests\Request;
|
2018-08-06 18:41:58 +03:00
|
|
|
use Date;
|
2017-09-14 22:21:00 +03:00
|
|
|
|
|
|
|
class InvoicePayment extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'account_id' => 'required|integer',
|
|
|
|
'paid_at' => 'required|date',
|
2018-08-30 11:58:38 +03:00
|
|
|
'amount' => 'required|amount',
|
2018-06-27 19:28:56 +03:00
|
|
|
'currency_code' => 'required|string|currency',
|
2017-09-14 22:21:00 +03:00
|
|
|
'payment_method' => 'required|string',
|
|
|
|
'attachment' => 'mimes:jpeg,jpg,png,pdf',
|
|
|
|
];
|
|
|
|
}
|
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
|
|
|
}
|