2024-08-11 07:28:51 +00:00
|
|
|
<?php
|
|
|
|
|
2024-08-13 04:54:42 +00:00
|
|
|
namespace Modules\Lpj\Http\Requests;
|
2024-08-11 07:28:51 +00:00
|
|
|
|
2024-09-04 13:27:13 +00:00
|
|
|
use daengdeni\LaravelIdGenerator\IdGenerator;
|
2024-08-13 04:54:42 +00:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2024-09-04 13:27:13 +00:00
|
|
|
use Illuminate\Support\Str;
|
2024-08-11 07:28:51 +00:00
|
|
|
|
2024-08-13 04:54:42 +00:00
|
|
|
class JenisJaminanRequest extends FormRequest
|
2024-08-11 07:28:51 +00:00
|
|
|
{
|
2024-08-13 04:54:42 +00:00
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
: array
|
|
|
|
{
|
2024-09-03 06:41:05 +00:00
|
|
|
return [
|
2024-09-04 13:27:13 +00:00
|
|
|
'code' => 'required|max:5',
|
|
|
|
'name' => 'required|max:255',
|
|
|
|
'slug' => 'required|max:255',
|
|
|
|
'jenis_legalitas_jaminan_id' => 'nullable',
|
2024-08-13 04:54:42 +00:00
|
|
|
];
|
2024-08-11 07:28:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-13 04:54:42 +00:00
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
: bool
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2024-09-03 06:41:05 +00:00
|
|
|
|
|
|
|
public function prepareForValidation()
|
|
|
|
: void
|
|
|
|
{
|
|
|
|
if ($this->method() == 'POST') {
|
|
|
|
$this->merge([
|
|
|
|
'code' => IdGenerator::generate(
|
|
|
|
['table' => 'jenis_jaminan', 'length' => 5, 'prefix' => 'JJ', 'field' => 'code'],
|
2024-09-04 13:27:13 +00:00
|
|
|
)
|
2024-09-03 06:41:05 +00:00
|
|
|
]);
|
|
|
|
}
|
2024-09-04 13:27:13 +00:00
|
|
|
|
|
|
|
$this->merge([
|
|
|
|
'jenis_legalitas_jaminan_id' => json_encode($this->jenis_legalitas_jaminan_id),
|
|
|
|
'slug' => Str::slug($this->name),
|
|
|
|
]);
|
2024-09-03 06:41:05 +00:00
|
|
|
}
|
2024-08-11 07:28:51 +00:00
|
|
|
}
|