50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Device extends Model
|
|
{
|
|
protected $table = 'device';
|
|
protected $primaryKey = 'device_id';
|
|
public $incrementing = true;
|
|
protected $keyType = 'int';
|
|
|
|
|
|
protected $fillable = [
|
|
'park_id',
|
|
'device_type',
|
|
'device_subject',
|
|
'device_identifier',
|
|
'device_work',
|
|
'device_workstart',
|
|
'device_replace',
|
|
'device_remarks',
|
|
'operator_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'park_id' => 'integer',
|
|
'device_workstart' => 'date',
|
|
'device_replace' => 'date',
|
|
'operator_id' => 'integer',
|
|
];
|
|
|
|
public function park()
|
|
{
|
|
return $this->belongsTo(Park::class, 'park_id', 'park_id');
|
|
}
|
|
|
|
|
|
public static function getList(): array
|
|
{
|
|
return static::orderBy('device_subject')->pluck('device_subject', 'device_id')->toArray();
|
|
}
|
|
|
|
public static function deleteByPk(array $ids): int
|
|
{
|
|
return static::whereIn('device_id', $ids)->delete();
|
|
}
|
|
}
|