Example #1
0
 public function actionSearch()
 {
     $str = '';
     if (isset($_POST['name'])) {
         $name = $_POST['name'];
         $icno = $_POST['icno'];
         if (!empty($name)) {
             $str = "name LIKE '%{$name}%'";
         }
         if (!empty($icno)) {
             $str = "icno = '{$icno}'";
         }
     }
     if (!empty($str)) {
         $visitors = Visitor::find()->where($str)->all();
     } else {
         $visitors = Visitor::find()->all();
     }
     return $this->render('search', ['visitors' => $visitors]);
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $visitor = Visitor::find($id);
     $visitor->punch_out = Carbon::now();
     $visitor->save();
     return redirect()->route('visitors.index');
 }