/**
  * [nextDate description]
  * @return [type] [description]
  */
 public function setVisitor(Request $request)
 {
     // Fetch cookie
     $cvuid_val = $request->cookie('CVUID');
     // Check if cookie exists
     if (isset($cvuid_val)) {
         $u = Visitor::where('session', '=', $cvuid_val)->first();
         // Check if user is alive
         if ($u != Null && $u->count() > 0) {
             $uid = $cvuid_val;
             $u->touch();
             //touch user to keep alive
         } else {
             // Create new user cause seems dead
             $uid = uniqid('_csnvaka', true);
             $v = new Visitor();
             $v->session = $uid;
             $v->save();
         }
     } else {
         // Create new user, cause totaly new :)
         $uid = uniqid('_csnvaka', true);
         $v = new Visitor();
         $v->session = $uid;
         $v->save();
     }
     // Create response with cookie
     $response = new Response($uid);
     $response->withCookie(cookie('CVUID', $uid, 720));
     return $response;
 }
Example #2
0
 public function insertDb()
 {
     $visitor = new Visitor();
     $visitor->ip = $this->ip;
     $visitor->browser = $this->browser;
     $visitor->position = $this->position;
     $visitor->save();
 }
 public function postRegister(Request $request)
 {
     //验证
     $this->validate($request, ['username' => 'required|max:255|unique:visitors', 'password' => 'required|min:6', 'email' => 'required|email|max:255|unique:visitors']);
     $visitor = new Visitor();
     $visitor->username = $request->input('username');
     $visitor->password = bcrypt($request->input('password'));
     $visitor->email = $request->input('email');
     $visitor->phone = $request->input('phone');
     $visitor->save();
     return redirect('auth/login');
     //return redirect($this->redirectPath('auth/login'))->with($this->statusVar, Lang::get('auth.addUserSuccess'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //$validator  = $this->validate($request, [
     //                'name' => 'required',
     //                'email' => 'required|email',
     //                'address' => 'required',
     //                'city' => 'required',
     //                'zipcode' => 'required',
     //            ]);
     $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:visitors', 'address' => 'required', 'city' => 'required', 'zipcode' => 'required']);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return redirect()->action('splashsController@index')->withErrors($validator)->withInput();
     } else {
         $visitor = new Visitor();
         $visitor->fill($request->except('_token'));
         $visitor->status = 'Active';
         $visitor->save();
         return redirect()->action('splashsController@index')->with('message', 'Thank you for your request!');
     }
 }
 public function handleCreate()
 {
     //print_r(Input::get('arival_date'));die;
     $visitor = new Visitor();
     $visitor->card_no = Input::get('card_no');
     $visitor->title = Input::get('title');
     $visitor->first_name = Input::get('first_name');
     $visitor->last_name = Input::get('last_name');
     $visitor->email = Input::get('email');
     $visitor->company_name = Input::get('company_name');
     $visitor->host_name = Input::get('host_name');
     $visitor->location = Input::get('location_id');
     $visitor->arival_date = Input::get('arival_date');
     $visitor->arival_timestamp = strtotime(Input::get('arival_date'));
     $visitor->arival_time = Input::get('arival_time');
     $visitor->status = Input::get('status');
     if (strpos(Input::get('image_url'), 'avatar/blank_face.jpg') !== false) {
         $visitor->avatar = 0;
     } else {
         $image_name = $this->createimage(Input::get('image_url'), Input::get('card_no'));
         $visitor->avatar = 1;
     }
     if (Input::get('signature_url') != "") {
         $signature_name = $this->createsignatureimage(Input::get('signature_url'), Input::get('card_no'));
         $visitor->signature = 1;
     } else {
         $visitor->signature = 0;
     }
     /*$host_details = Employee::where('id', '=', Input::get('host_name'))->get();*/
     $hostname = Employee::where('id', '=', Input::get('host_name'))->pluck('name');
     $hostemail = Employee::where('id', '=', Input::get('host_name'))->pluck('email');
     if ($visitor->save()) {
         $visitorRole = new VisitorRole();
         $visitorRole->visitor_id = $visitor->id;
         $visitorRole->role_id = Input::get('role_id');
         $visitorRole->save();
         /*Mail::send('Hii', function($message)
         		{
         			$message->from('*****@*****.**', 'Amaze Apps');
         			$message->to('*****@*****.**')->subject('Visitor Meeting');
         		});*/
         $message = "<html><head><title></title>\n\t\t\t<style>\n\t\t\tbody, table {\n\t\t\t\t\tcolor: #2D2D2D;\n\t\t\t\t\tfont-family: Tahoma,Geneva,sans-serif;\n\t\t\t\t\tfont-size: 12px;\n\t\t\t}\n\t\t\t</style>\n\t\t\t</head><body>\n\t\t\tDear " . $hostname . ",<br/><br/>\n\t\t\tYour visitor " . Input::get('title') . " " . Input::get('first_name') . " " . Input::get('last_name') . " from " . Input::get('company_name') . "  arrived at reception and waiting for your pre-scheduled meeting. <br/>\n\t\t\tThis is for your information. <br /><br />";
         $message .= "Thanks,<br/>\n\t\t\t\t\t" . Auth::user()->name . "<br/>\n\t\t\t\t\t" . Location::where('id', '=', Auth::user()->location_id)->pluck('name') . "\n\t\t\t\t\t</body><html>";
         $subject = "Visitor Meeting";
         $headers = "MIME-Version: 1.0" . "\r\n";
         $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
         $headers .= "From: Amaze Apps< " . Auth::user()->email . "  >";
         $to = $hostemail;
         $mail_sent = @mail($to, $subject, $message, $headers);
         return Response::json(array('success' => 'Appointment has been done!'));
     }
 }