routeIs('lecturer.*')) { return (bool) $this->user()->lecturer; } return true; } public function rules(): array { if ($this->routeIs('lecturer.*')) { $lecturer = $this->user()->lecturer; $adviseeIds = $lecturer ? $lecturer->advisees()->pluck('id') : collect(); return [ 'student_id' => ['required', 'integer', Rule::in($adviseeIds)], 'topic' => ['nullable', 'string', 'max:150'], 'notes' => ['nullable', 'string'], 'session_date' => ['nullable', 'date'], ]; } return [ 'student_id' => ['required', 'integer', Rule::exists('students', 'id')], 'lecturer_id' => ['required', 'integer', Rule::exists('lecturers', 'id')], 'topic' => ['nullable', 'string', 'max:150'], 'notes' => ['nullable', 'string'], 'session_date' => ['nullable', 'date'], ]; } public function messages(): array { return [ 'student_id.in' => 'Mahasiswa yang dipilih bukan mahasiswa bimbingan Anda.', ]; } }