lpj/app/Http/Requests/DebitureRequest.php

51 lines
1.7 KiB
PHP
Raw Normal View History

2024-08-13 04:50:40 +00:00
<?php
namespace Modules\Lpj\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class DebitureRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules()
: array
{
$rules = [
'branch_id' => 'required|exists:branches,id',
'province_code' => 'nullable|exists:provinces,code',
'city_code' => 'nullable|exists:cities,code',
'district_code' => 'nullable|exists:districts,code',
'village_code' => 'nullable|exists:villages,code',
'nomor_rekening' => 'nullable|string|max:50',
'name' => 'required',
'registered_at' => 'nullable|date',
'npwp' => 'nullable|string|max:16',
'nomor_id' => 'nullable|string|max:16',
'email' => 'nullable|email',
'phone' => 'nullable|string|max:15',
'address' => 'nullable|string',
'postal_code' => 'nullable|string|max:10',
'status' => 'nullable|boolean'
];
if ($this->method() == 'PUT') {
$rules['cif'] = 'required|unique:debitures,cif,' . $this->id;
} else {
$rules['cif'] = 'required|unique:debitures,cif';
}
return $rules;
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize()
: bool
{
return true;
}
}