Add Notes model, controller and database table. Implement it in Customer Dialog, #6

This commit is contained in:
2025-11-21 13:23:13 +01:00
parent 739bf81bc9
commit b1a258f36d
11 changed files with 396 additions and 47 deletions
+8 -1
View File
@@ -27,7 +27,6 @@ class Customer extends Model
'billing_address',
'payment_terms_id',
'status',
'notes',
'logo',
];
@@ -96,4 +95,12 @@ public function paymentTerms()
{
return $this->belongsTo(PaymentTerms::class);
}
/**
* Get the notes for the customer
*/
public function notes()
{
return $this->morphMany(Note::class, 'notable');
}
}
+29
View File
@@ -0,0 +1,29 @@
<?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);
}
public function notable()
{
return $this->morphTo();
}
}