2025-11-21 13:23:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Note extends Model
|
|
|
|
|
{
|
|
|
|
|
/** @use HasFactory<\Database\Factories\NoteFactory> */
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'user_id',
|
|
|
|
|
'text',
|
|
|
|
|
'notable_id',
|
|
|
|
|
'notable_type'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-17 10:35:03 +01:00
|
|
|
// Polymorphic relationship to the notable model (e.g., Lead, Contact, PipelineItem, etc.)
|
|
|
|
|
// https://laravel.com/docs/12.x/eloquent-relationships#one-to-many-polymorphic-relations
|
2025-11-21 13:23:13 +01:00
|
|
|
public function notable()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphTo();
|
|
|
|
|
}
|
|
|
|
|
}
|