File manager - Edit - /var/www/html/spdc/api/app/Models/Transportation.php
Back
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; class Transportation extends Model { use HasFactory; use HasUuids; protected $fillable = [ 'model', 'autonomy', 'initial_odometer', 'fuel_capacity', 'identification_code', 'vehicle_type_id', 'category', 'engine' ]; protected $casts = [ 'autonomy' => 'float', 'initial_odometer' => 'float', 'fuel_capacity' => 'float' ]; protected $appends = [ 'current_odometer' ]; /** * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ protected function currentOdometer(): Attribute { return new Attribute( get: fn () => $this->supplies()->exists() ? $this->supplies()->latest()->first()?->odometer : $this->initial_odometer, ); } /** * Get the vehicleType that owns the Transportation * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function vehicleType(): BelongsTo { return $this->belongsTo(VehicleType::class); } /** * Get all of the status for the Transportation * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function status(): HasMany { return $this->hasMany(TransportationStatus::class); } /** * Get all of the schedules for the Transportation * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function schedules(): HasMany { return $this->hasMany(Schedule::class); } /** * Get all of the bdts for the Transportation * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function bdts(): HasMany { return $this->hasMany(BDT::class); } /** * Get all of the supplies for the Transportation * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function supplies(): HasMany { return $this->hasMany(TransportationSupply::class); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings