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 Visit extends SoftDeletesModel
|
|
|
|
|
{
|
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
|
|
|
|
|
|
protected $appends = ['type_text', 'audit_status_text', 'file_detail'];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'follw_people' => 'array',
|
|
|
|
|
'cars' => 'array',
|
|
|
|
|
'file' => 'array'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function getFileDetailAttribute()
|
|
|
|
|
{
|
|
|
|
|
if (empty($this->file)) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
return Upload::whereIn('id', $this->file)->get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getTypeTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
$array = [1 => '普通访客', 2 => '施工访客', 3 => '物流访客'];
|
|
|
|
|
return $array[$this->type] ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAuditStatusTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
$array = [-1 => '待学习', 0 => '待审核', 1 => '通过', 2 => '驳回', 3 => '已进厂', 4 => '已离厂'];
|
|
|
|
|
return $array[$this->type] ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function visitTime()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(VisitTime::class, 'id', 'visit_time_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function admin()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(Admin::class, 'id', 'admin_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|