'datetime', ]; public function user() { return $this->belongsTo(User::class, 'changed_by'); } /** * Get the parent document model (quote or invoice). */ public function document() { // define a custom polymorphic relationship or helper if needed // Since it is an enum, we can't use standard morphTo easily without a map. // But for now, I will just leave it or maybe add a helper. // Standard Laravel morph expects 'document_type' to be the class name. // Here it is 'quote' or 'invoice'. // We can use morphMap in AppServiceProvider to map 'quote' => Quote::class. return $this->morphTo(__FUNCTION__, 'document_type', 'document_id'); } }