'boolean', ]; // 🔧 Configure Spatie logging public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->useLogName('photo') ->logFillable() ->logOnlyDirty(); } // 📝 Custom activity description for events public function getDescriptionForEvent(string $eventName): string { return match ($eventName) { 'created' => 'Added new photo', 'updated' => 'Updated photo details', 'deleted' => 'Deleted photo', default => ucfirst($eventName) . ' photo record', }; } // 🔗 Relationships public function person() { return $this->belongsTo(Person::class, 'person_id', 'person_id'); } // Helper method to set a photo as profile photo public function setAsProfilePhoto(): bool { // First unset any existing profile photo for this person if ($this->person_id) { self::where('person_id', $this->person_id) ->where('is_profile_photo', true) ->update(['is_profile_photo' => false]); } // Set this photo as profile photo $this->is_profile_photo = true; return $this->save(); } }