31 lines
964 B
PHP
31 lines
964 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Management;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreWheelchairTransactionRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->hasRole('Admin') === true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'transaction_type' => ['required', Rule::in(['taken', 'returned'])],
|
|
'quantity' => ['required', 'integer', 'min:1', 'max:9999'],
|
|
'taken_at' => ['nullable', 'date'],
|
|
'taken_by_name' => ['nullable', 'string', 'max:255', 'required_if:transaction_type,taken'],
|
|
'returned_at' => ['nullable', 'date'],
|
|
'return_condition' => ['nullable', Rule::in(['baik', 'rosak']), 'required_if:transaction_type,returned'],
|
|
'notes' => ['nullable', 'string', 'max:2000'],
|
|
];
|
|
}
|
|
}
|