Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

akaunting/akaunting

9348 stars
1 code files
View akaunting/akaunting on GitHub

app/Http/Requests/Banking/Transaction.php

Open in GitHub
use App\Abstracts\Http\FormRequest;
use App\Utilities\Date;
 
class Transaction extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$attachment = 'nullable';
 
if ($this->files->get('attachment')) {
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
}
 
return [
'type' => 'required|string',
'account_id' => 'required|integer',
'paid_at' => 'required|date_format:Y-m-d H:i:s',
'amount' => 'required|amount',
'currency_code' => 'required|string|currency',
'currency_rate' => 'required|gt:0',
'document_id' => 'nullable|integer',
'contact_id' => 'nullable|integer',
'category_id' => 'required|integer',
'payment_method' => 'required|string',
'attachment.*' => $attachment,
];
}
 
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);
}
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.