Extend invoices and invoice items to keep more information.

This commit is contained in:
2025-01-31 13:04:59 +01:00
parent e2240c017d
commit d8afe4960e
20 changed files with 1475 additions and 640 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Project extends Model
@@ -33,8 +34,20 @@ class Project extends Model
protected $appends = [
'start',
'end',
'customer_email',
'customer_name',
];
public function getCustomerNameAttribute(): string
{
return $this->customer->name;
}
public function getCustomerEmailAttribute(): string
{
return $this->customer->email;
}
/**
* Get the end_date attribute in local format.
*/
@@ -58,4 +71,9 @@ class Project extends Model
{
return $this->belongsTo(Customer::class);
}
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
}