Extend invoices and invoice items to keep more information.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user