You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
58 lines
1.3 KiB
<?php |
|
|
|
namespace App\Models; |
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
class Intervaldis extends Model |
|
{ |
|
use HasFactory; |
|
protected $table = 'intervaldis'; |
|
|
|
protected $fillable = [ |
|
'start_serialnumber', |
|
'end_serialnumber', |
|
'distance', |
|
'limit_speed', |
|
'outlaw_speed', |
|
'limit_time', |
|
'speed_alert', |
|
'count_alert', |
|
'location', |
|
'location_id', |
|
'certificatenumber', |
|
'crosspathban', |
|
'carkindban', |
|
'start_cert', |
|
'end_cert', |
|
]; |
|
protected $hidden = [ |
|
'created_at', |
|
'updated_at', |
|
'deleted_at' |
|
]; |
|
|
|
protected $appends = ['start_num', 'end_num']; |
|
|
|
public function getStartNumAttribute() |
|
{ |
|
return IntervalEquipment::find($this->start_serialnumber)->serialnumber; |
|
} |
|
|
|
public function getEndNumAttribute() |
|
{ |
|
return IntervalEquipment::find($this->end_serialnumber)->serialnumber; |
|
} |
|
|
|
public function start() |
|
{ |
|
return $this->belongsTo(IntervalEquipment::class, 'start_serialnumber', 'serialnumber'); |
|
} |
|
|
|
public function end() |
|
{ |
|
return $this->belongsTo(IntervalEquipment::class, 'end_serialnumber', 'serialnumber'); |
|
} |
|
|
|
}
|
|
|