61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class DetailLaporanRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'tanggal' => 'required|date_format:Y-m-d|before_or_equal:today',
|
|
'sales_id' => 'nullable|integer|exists:sales,id',
|
|
'nampan_id' => 'nullable|integer',
|
|
'produk_id' => 'nullable|integer|exists:produks,id',
|
|
'nama_pembeli' => 'nullable|string|max:255',
|
|
'page' => 'nullable|integer|min:1',
|
|
'per_page' => 'nullable|integer|min:1|max:100',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validator errors.
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'tanggal.required' => 'Tanggal harus diisi',
|
|
'tanggal.date_format' => 'Format tanggal harus Y-m-d',
|
|
'tanggal.before_or_equal' => 'Tanggal tidak boleh lebih dari hari ini',
|
|
'sales_id.exists' => 'Sales tidak ditemukan',
|
|
'produk_id.exists' => 'Produk tidak ditemukan',
|
|
'nama_pembeli.max' => 'Nama pembeli maksimal 255 karakter',
|
|
'page.min' => 'Page minimal 1',
|
|
'per_page.min' => 'Per page minimal 1',
|
|
'per_page.max' => 'Per page maksimal 100',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'page' => $this->query('page', 1),
|
|
'per_page' => $this->query('per_page', 15),
|
|
]);
|
|
}
|
|
} |