'boolean', 'is_active' => 'boolean', 'assigned_at' => 'datetime', ]; public function user() { return $this->belongsTo(User::class, 'user_id'); } public function chapter() { return $this->belongsTo(Chapter::class, 'chapter_id'); } public function isOfficer(): bool { return !empty($this->role) && $this->role !== 'MEMBER'; } /** * Sync auto-assignment for a user to a chapter — only if no manual override exists. */ public static function syncAutoAssignment(int $userId, int $chapterId): void { static::updateOrCreate( ['user_id' => $userId, 'chapter_id' => $chapterId], [ 'is_active' => true, 'is_manual_override' => false, // Only sync if we're not overriding? // Actually the rule is: if it exists, only update if NOT manual override. // updateOrCreate doesn't support conditional update easily. ] ); } }