*/ protected $fillable = [ 'customer_id', 'name', 'project_number', 'description', 'start_date', 'end_date', ]; /** * The attributes that are appended with attribute getters. * * @var string[] */ 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. */ public function getStartAttribute(): string { return (is_null($this->start_date)) ? '' : Carbon::createFromFormat('Y-m-d', $this->start_date)->format('d.m.Y'); } /** * Get the end_date attribute in local format. */ public function getEndAttribute(): string { return (is_null($this->end_date)) ? '' : Carbon::createFromFormat('Y-m-d', $this->end_date)->format('d.m.Y'); } /** * Get the customer this project belongs to. */ public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } public function invoices(): HasMany { return $this->hasMany(Invoice::class); } }