File manager - Edit - /home/autoph/public_html/projects/aha-api/app/Models/CarLine.php
Back
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use OwenIt\Auditing\Contracts\Auditable; use Illuminate\Database\Eloquent\SoftDeletes; use OwenIt\Auditing\Auditable as AuditableTrait; use Illuminate\Database\Eloquent\Factories\HasFactory; class CarLine extends Model implements Auditable { use HasFactory, SoftDeletes, AuditableTrait; protected $table = 'models'; /** * The attributes that are NOT mass assignable. * */ protected $guarded = [ 'deleted_at', ]; protected $appends = [ 'image_url', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; /** * Get the Brand that owns the Model * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function brand() { return $this->belongsTo(Brand::class); } public function variants() { return $this->hasMany(ModelVariant::class, 'model_id'); } public function colors() { return $this->hasMany(ModelColor::class, 'model_id'); } public function getImageUrlAttribute() { $data = ModelColor::where('model_id', $this->id)->whereNotNull('image')->first(); if($data) return env('APP_URL').'/images/car-lines/'.sprintf('%03d',$this->brand_id).'/'.$data->image; return null; } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings