|string> */ public function rules(): array { return [ 'name' => ['required', 'max:100'], 'year' => ['required', 'max:5'], 'description' => ['nullable'], 'slug' => ['required'], 'enhancer_id' => ['required'], ]; } public function messages(): array { return [ 'name.required' => 'Nama harus diisi.', 'name.max' => 'Nama tidak boleh lebih dari 100 karakter.', 'year.required' => 'Tahun harus diisi.', 'year.max' => 'Tahun tidak boleh lebih dari 5 karakter.', 'description.nullable' => 'Deskripsi bersifat opsional.', ]; } protected function prepareForValidation() { $this->merge([ 'slug' => filled($this->name) && filled($this->year) ? \Illuminate\Support\Str::slug($this->name.' '.$this->year) : null, 'enhancer_id' => Auth::check() ? Auth::id() : null, ]); } }