|
@@ -12,6 +12,7 @@ use App\Models\Project;
|
|
use App\Models\WorkPoint;
|
|
use App\Models\WorkPoint;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
+use phpDocumentor\Reflection\DocBlock;
|
|
|
|
|
|
class InnerDeviceController extends BaseController
|
|
class InnerDeviceController extends BaseController
|
|
{
|
|
{
|
|
@@ -49,7 +50,7 @@ class InnerDeviceController extends BaseController
|
|
|
|
|
|
public function get(Request $request)
|
|
public function get(Request $request)
|
|
{
|
|
{
|
|
- $items = $this->model->where('id', '>', 0)->with(['device', 'spec', 'device_name']);
|
|
|
|
|
|
+ $items = $this->model->where('id', '>', 0)->with(['device', 'spec', 'device_name','inner_device_names']);
|
|
|
|
|
|
$tmp_items = collect(['number']);
|
|
$tmp_items = collect(['number']);
|
|
foreach($tmp_items as $tmp_item) {
|
|
foreach($tmp_items as $tmp_item) {
|
|
@@ -64,13 +65,13 @@ class InnerDeviceController extends BaseController
|
|
$items = $items->where($select_item, '=', $request->input($select_item));
|
|
$items = $items->where($select_item, '=', $request->input($select_item));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //排序
|
|
$items = $items->orderBy('updated_at', 'desc')->paginate();
|
|
$items = $items->orderBy('updated_at', 'desc')->paginate();
|
|
-
|
|
|
|
|
|
+// dd($items);
|
|
foreach ($items as $item) {
|
|
foreach ($items as $item) {
|
|
$item->device_type = $item->device ? $item->device->name : '';
|
|
$item->device_type = $item->device ? $item->device->name : '';
|
|
- $item->device_name_name = $item->device_name ? $item->device_name->name : '';
|
|
|
|
- $item->spec_name = $item->spec ? $item->spec->name : '';
|
|
|
|
|
|
+ $item->device_name_name = $item->inner_device_names ? $item->inner_device_names->name : '';
|
|
|
|
+ $item->spec_name = $item->spec_name ? $item->spec_name : '';
|
|
$item->status = $item->getStatusLabel();
|
|
$item->status = $item->getStatusLabel();
|
|
$item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
|
|
$item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
|
|
$item->project_name = $item->project ? $item->project->name : '';
|
|
$item->project_name = $item->project ? $item->project->name : '';
|
|
@@ -102,7 +103,8 @@ class InnerDeviceController extends BaseController
|
|
return back()->withErrors($validator)->withInput();
|
|
return back()->withErrors($validator)->withInput();
|
|
}
|
|
}
|
|
$data = $request->input('data');
|
|
$data = $request->input('data');
|
|
- $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
|
|
|
|
|
|
+// dd($data);
|
|
|
|
+ $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', 'project_id', 'work_point_id']));
|
|
$res = $this->model->create($data);
|
|
$res = $this->model->create($data);
|
|
if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
|
|
if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
|
|
return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
|
|
return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
|
|
@@ -134,7 +136,7 @@ class InnerDeviceController extends BaseController
|
|
return back()->withErrors($validator)->withInput();
|
|
return back()->withErrors($validator)->withInput();
|
|
}
|
|
}
|
|
$data = $request->input('data');
|
|
$data = $request->input('data');
|
|
- $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
|
|
|
|
|
|
+ $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', 'project_id', 'work_point_id']));
|
|
$res = $this->model->where('id', $request->input('id'))->update($data);
|
|
$res = $this->model->where('id', $request->input('id'))->update($data);
|
|
if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
|
|
if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
|
|
return back()->with(['sg_success_info' => '编辑成功']);
|
|
return back()->with(['sg_success_info' => '编辑成功']);
|