| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | 
							- <?php
 
- namespace App\Models;
 
- use Illuminate\Http\Request;
 
- use Illuminate\Support\Facades\Validator;
 
- class InnerDevice extends BaseModel
 
- {
 
-     public function workPoint()
 
-     {
 
-         return $this->belongsTo('App\Models\WorkPoint', 'work_point_id');
 
-     }
 
-     public function project()
 
-     {
 
-         return $this->belongsTo('App\Models\Project', 'project_id');
 
-     }
 
-     public function spec()
 
-     {
 
-         return $this->belongsTo('App\Models\Spec', 'spec_id');
 
-     }
 
-     public function device()
 
-     {
 
-         return $this->belongsTo('App\Models\Device', 'device_id');
 
-     }
 
-     public function device_name()
 
-     {
 
-         return $this->belongsTo('App\Models\DeviceName', 'device_name_id');
 
-     }
 
-     public function devices_name(){
 
-         return $this->hasOne(InnerDeviceNamesModel::class,'id','device_name_id');
 
-     }
 
-     public function option()
 
-     {
 
-         return $this->belongsTo('App\Models\Option', 'status');
 
-     }
 
-     public function getValidator(Request $request, $type)
 
-     {
 
-         $validator = Validator::make($request->input('data'), [
 
-             'number' => 'required'
 
-         ], [
 
-             'number.required' => '固定资产编号'
 
-         ]);
 
- //        $validator->after(function ($validator) use($request) {
 
- //            if (!$request->input('device_name_id')) {
 
- //                $validator->errors()->add('device_name_id', '设备名称必填');
 
- //            }
 
- //            if (!$request->input('spec_id')) {
 
- //                $validator->errors()->add('spec_id', '规格型号必填');
 
- //            }
 
- //        });
 
-         return $validator;
 
-     }
 
-     public function getStatusLabel()
 
-     {
 
-         return $this['option'] ? '<div style="color: ' . $this['option']['color'] . '">' . $this['option']['name'] . '</div>' : '';
 
-     }
 
-     public function inner_device_names(){
 
-         return $this->hasOne(InnerDeviceNamesModel::class,'id','device_name_id');
 
-     }
 
- }
 
 
  |