'responsibility/cooperative/collaborator/index', 'show' => 'responsibility/cooperative/collaborator/show', ]; public function __construct() { parent::__construct(); $this->model = new Collaborator(); } public function index(Request $request) { if ($request->isAjax()) { $collaborator = new CollaboratorService(); $list = $collaborator->index($request); return sparKSuccess(dataReturn(0, 'success', $list)); } return view($this->templates['index']); } public function getList() { Collaborator::truncate(); $listData = DB::connection('mysql2')->table('sha_db_sgyth_labour_worker_f_d')->get()->toArray(); $postData = array(); foreach ($listData as $key => $value) { $item = array(); $item['worker_id'] = $value->workerid; $item['name'] = $value->name; $item['cell_phone'] = $value->cellphone; $item['id_no'] = $value->idno; $item['group_name'] = $value->groupname; $item['team_name'] = $value->teamname; $item['group_id'] = $value->groupid; $item['team_id'] = $value->teamid; $item['project_name'] = $value->projectname; $item['dept_code'] = $value->deptcode; $item['work_type_name'] = $value->worktypename; $item['in_date'] = $value->indate; $item['out_date'] = $value->outdate; array_push($postData, $item); } Collaborator::insertOrIgnore($postData); return sparkSuccess(dataReturn(0, 'success')); } public function show(Request $request, $id): Response { $data = $this->model->where('worker_id', $id)->first(); if (!$data) { return view('common/404')->withStatus(404); } View::assign([ 'data' => $data ]); return view($this->templates['show']); } }