*/ protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; protected $appends = [ 'image_url' ]; /** * Get the Car Line/ Model that owns the Colors * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function model() { return $this->belongsTo(CarLine::class); } public function getImageUrlAttribute() { return env('APP_URL').'/images/car-lines/'.sprintf('%03d', CarLine::find($this->model_id)->brand_id).'/'.$this->image; } }