|
@@ -7,6 +7,9 @@ use Illuminate\Support\Facades\Validator;
|
|
|
|
|
|
class InnerDevice extends BaseModel
|
|
class InnerDevice extends BaseModel
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+ protected $appends = ['inner_name'];
|
|
|
|
+
|
|
public function workPoint()
|
|
public function workPoint()
|
|
{
|
|
{
|
|
return $this->belongsTo('App\Models\WorkPoint', 'work_point_id');
|
|
return $this->belongsTo('App\Models\WorkPoint', 'work_point_id');
|
|
@@ -29,7 +32,9 @@ class InnerDevice extends BaseModel
|
|
|
|
|
|
public function device_name()
|
|
public function device_name()
|
|
{
|
|
{
|
|
- return $this->belongsTo('App\Models\DeviceName', 'device_name_id');
|
|
|
|
|
|
+// return $this->belongsTo('App\Models\DeviceName', 'device_name_id');
|
|
|
|
+ return $this->hasOne(InnerDeviceNamesModel::class,'id','device_name_id');
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
public function devices_name(){
|
|
public function devices_name(){
|
|
@@ -58,6 +63,11 @@ class InnerDevice extends BaseModel
|
|
return $validator;
|
|
return $validator;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function getInnerNameAttribute($value)
|
|
|
|
+ {
|
|
|
|
+ $id = $this->attributes['device_name_id'];
|
|
|
|
+ return InnerDeviceNamesModel::where(['id'=>$id])->value('name');
|
|
|
|
+ }
|
|
public function getStatusLabel()
|
|
public function getStatusLabel()
|
|
{
|
|
{
|
|
return $this['option'] ? '<div style="color: ' . $this['option']['color'] . '">' . $this['option']['name'] . '</div>' : '';
|
|
return $this['option'] ? '<div style="color: ' . $this['option']['color'] . '">' . $this['option']['name'] . '</div>' : '';
|