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.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
class GateLog extends CommonModel
|
|
|
|
|
{
|
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'person_no' => 'json',
|
|
|
|
|
'car_no' => 'json'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $appends = ['action_text'];
|
|
|
|
|
|
|
|
|
|
public function getActionTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
$array = [1 => '进厂', 2 => '离厂'];
|
|
|
|
|
return $array[$this->action] ?? ($this->remark ?? '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function admin()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(Admin::class, 'id', 'admin_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function add($admin_id, $code, $person_no, $car_no, $remark = '', $visit_id = null, $action = null, $biz_date = null)
|
|
|
|
|
{
|
|
|
|
|
return self::create([
|
|
|
|
|
'admin_id' => $admin_id,
|
|
|
|
|
'visit_id' => $visit_id,
|
|
|
|
|
'code' => $code,
|
|
|
|
|
'action' => $action,
|
|
|
|
|
'car_no' => $car_no,
|
|
|
|
|
'person_no' => $person_no,
|
|
|
|
|
'remark' => $remark,
|
|
|
|
|
'biz_date' => $biz_date
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|