/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Technician::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['tech_id' => $this->tech_id, 'tech_exp_month' => $this->tech_exp_month, 'tech_exp_year' => $this->tech_exp_year, 'tech_contact' => $this->tech_contact, 'post_date' => $this->post_date, 'status' => $this->status, 'tech_specialty_id' => $this->tech_specialty_id, 'pay_status' => $this->pay_status, 'pay_date' => $this->pay_date]); $query->andFilterWhere(['like', 'tech_nickname', $this->tech_nickname])->andFilterWhere(['like', 'tech_full_name', $this->tech_full_name])->andFilterWhere(['like', 'tech_lname', $this->tech_lname])->andFilterWhere(['like', 'tech_email', $this->tech_email])->andFilterWhere(['like', 'tech_pics', $this->tech_pics])->andFilterWhere(['like', 'tech_resume', $this->tech_resume])->andFilterWhere(['like', 'tech_bio', $this->tech_bio])->andFilterWhere(['like', 'share_bio', $this->share_bio])->andFilterWhere(['like', 'tech_disclamer', $this->tech_disclamer])->andFilterWhere(['like', 'tech_license', $this->tech_license])->andFilterWhere(['like', 'tech_employment', $this->tech_employment])->andFilterWhere(['like', 'tech_emp_address_street', $this->tech_emp_address_street])->andFilterWhere(['like', 'tech_emp_address_city', $this->tech_emp_address_city])->andFilterWhere(['like', 'tech_emp_address_state', $this->tech_emp_address_state])->andFilterWhere(['like', 'tech_emp_address_zip', $this->tech_emp_address_zip])->andFilterWhere(['like', 'tech_subscription_active', $this->tech_subscription_active])->andFilterWhere(['like', 'tech_credit_type', $this->tech_credit_type])->andFilterWhere(['like', 'tech_credit_card', $this->tech_credit_card])->andFilterWhere(['like', 'tech_credit_ver', $this->tech_credit_ver])->andFilterWhere(['like', 'tech_fname_cc', $this->tech_fname_cc])->andFilterWhere(['like', 'tech_lname_cc', $this->tech_lname_cc])->andFilterWhere(['like', 'tech_school', $this->tech_school])->andFilterWhere(['like', 'tech_disinfection_verified', $this->tech_disinfection_verified])->andFilterWhere(['like', 'tech_profile', $this->tech_profile])->andFilterWhere(['like', 'tech_pass', $this->tech_pass])->andFilterWhere(['like', 'sh_tech_contact', $this->sh_tech_contact])->andFilterWhere(['like', 'sh_tech_email', $this->sh_tech_email])->andFilterWhere(['like', 'curr_employment', $this->curr_employment])->andFilterWhere(['like', 'sh_tech_school', $this->sh_tech_school])->andFilterWhere(['like', 'shared_profile', $this->shared_profile])->andFilterWhere(['like', 'transaction_id', $this->transaction_id])->andFilterWhere(['like', 'ret_cust_id', $this->ret_cust_id])->andFilterWhere(['like', 'return_string', $this->return_string]); return $dataProvider; }
/** * Finds the Technician model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Technician the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Technician::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
}); // ===== auto complete routes ===== Route::get('toolnames', function () { $toolnames = collect(\App\Models\Tool::lists("name")); return $toolnames->unique()->values()->all(); }); Route::get('technames', function () { $technames = collect(\App\Models\Technician::lists("tech_name")); return $technames->unique()->values()->all(); }); Route::get('techcompanies', function () { $techcompanies = collect(\App\Models\Technician::lists("tech_company")); return $techcompanies->unique()->values()->all(); }); Route::get('technumbers', function () { $technumbers = collect(\App\Models\Technician::lists("contact_number")); return $technumbers->unique()->values()->all(); }); // ===== donut charts routes ===== Route::get('countnotifications', function () { $user = \Auth::user(); $usernotifications = $user->notifications->where('has_read', 'No')->count(); return $usernotifications; }); Route::get('countpersonaltools', function () { $user = \Auth::user(); $usertools = $user->tools()->where('type', 'Personal')->count(); return $usertools; }); Route::get('countcompanytools', function () { $user = \Auth::user();
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $technician = \App\Models\Technician::create($request->all()); $technician->save(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(UpdateToolRequest $request, $id) { // $tool = \App\Models\Tool::find($id); $tool->fill($request->all()); $type = \Request::get("type"); // if company tool has been transferred $iPreviousSiteID = $tool->user->site_id; if ($tool->user->site_id != $request->get("site_id")) { $iNewSiteID = \App\Models\Site::find($request->get("site_id"))->users()->where("admin", "=", "Yes")->first()->site_id; $tool->user_id = \App\Models\Site::find($request->get("site_id"))->users()->where("admin", "=", "Yes")->first()->id; // send notification $notification = new \App\Models\Notification(); $notification->message = '<a href="' . url("tools/" . $tool->id) . '">' . $tool->name . '</a>' . " has been transferred to this job site."; $notification->user_id = $tool->user_id; $notification->save(); //send email Mail::send('emails.transfers', ['tool' => $tool], function ($m) { $m->from('*****@*****.**', 'Tag and Track'); $m->to('*****@*****.**', 'Leanne')->subject('Company Tool has been transferred'); }); // transfers table $transfer = new \App\Models\Transfer(); $transfer->previous_site_id = $iPreviousSiteID; $transfer->current_site_id = $iNewSiteID; $transfer->tool_id = $tool->id; $transfer->save(); } // reset notifications flags, when retag date changes if ($tool->retag_date != $request->get("retag_date")) { $tool->five_notice = 0; $tool->three_notice = 0; $tool->one_notice = 0; } $tool->save(); if ($request->has('tech_name')) { $name = $request->get('tech_name'); $company = $request->get('tech_company'); $phone = $request->get('contact_number'); $technician = \App\Models\Technician::where("tech_name", '=', $name)->where("tech_company", '=', $company)->where("contact_number", '=', $phone)->first(); // if technician doesn't exist if ($technician == false) { $technician = Technician::create($request->all()); } $tool->technician_id = $technician->id; $tool->save(); } if ($type == "Company") { return redirect('tools?type=Company')->with('message-update', 'Update successful.'); } else { return redirect('tools?type=Personal')->with('message-update', 'Update successful.'); } }