'required|max:5', 'name' => 'required|max:255', 'slug' => 'required|max:255', 'jenis_legalitas_jaminan_id' => 'nullable', ]; } /** * Determine if the user is authorized to make this request. */ public function authorize() : bool { return true; } public function prepareForValidation() : void { if ($this->method() == 'POST') { $this->merge([ 'code' => IdGenerator::generate( ['table' => 'jenis_jaminan', 'length' => 5, 'prefix' => 'JJ', 'field' => 'code'], ) ]); } $this->merge([ 'jenis_legalitas_jaminan_id' => json_encode($this->jenis_legalitas_jaminan_id), 'slug' => Str::slug($this->name), ]); } }