Your IP : 216.73.216.91


Current Path : /var/www/html/LLCF-APP/app/Http/Requests/
Upload File :
Current File : /var/www/html/LLCF-APP/app/Http/Requests/ExpenseFormRequest.php

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ExpenseFormRequest extends FormRequest
{
    public function authorize(): bool
    {
        return auth()->guard('admin')->check();
    }

    public function rules(): array
    {
        return [
            'item_id' => 'required|exists:items,id',
            'date' => 'required|date_format:Y-m-d',
            'type' => 'required|in:llcf,bocado',
            'amount' => 'required|numeric|min:0',
        ];
    }

    public function messages(): array
    {
        return [
            'item_id.required' => 'Please select an item.',
            'item_id.exists' => 'The selected item is invalid.',
            'date.required' => 'Please provide a date.',
            'date.date_format' => 'Date must be in Y-m-d format.',
            'type.required' => 'Please select a type.',
            'type.in' => 'Type must be either llcf or bocado.',
            'amount.required' => 'Please enter an amount.',
            'amount.numeric' => 'Amount must be numeric.',
            'amount.min' => 'Amount must be greater than or equal to 0.',
        ];
    }
}