'required|max:6', 'name' => 'required|max:255', 'slug' => 'required|max:255', ]; } /** * Determine if the user is authorized to make this request. */ public function authorize() : bool { return true; } public function prepareForValidation() { if($this->method() == 'POST' && $this->code == null) { $this->merge([ 'code' => IdGenerator::generate( ['table' => 'jenis_legalitas_jaminan', 'length' => 6, 'prefix' => 'JLJ', 'field' => 'code'], ), 'slug' => Str::slug($this->name), ]); } else { $this->merge([ 'slug' => Str::slug($this->name), ]); } } }