/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     for ($i = 1; $i < 5; $i++) {
         Guestinfo::create(['guestId' => rand(1, 10), 'ipAddress' => '127.0.0.1', 'userAgent' => 'Mozilla/5.0 (X11; Linux x86_64)', 'country' => 'china', 'area' => 'zhejiang', 'region' => 'adsj', 'city' => 'jiaxing']);
     }
 }
Beispiel #2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //
     $guestinfos = Guestinfo::allGuestinfos();
     if (isset($guestinfos)) {
         return view('blog.cms.guestinfo.index')->with('guestinfos', $guestinfos);
     } else {
         abort(404);
     }
 }
Beispiel #3
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $clientIp = $_SERVER['REMOTE_ADDR'];
     $userAgent = $_SERVER['HTTP_USER_AGENT'];
     $Res = json_decode(file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip=' . $clientIp));
     $status = $Res->code;
     $ipData = $Res->data;
     $guestinfo = new Guestinfo();
     $guestinfo->guestId = $Res->code;
     $guestinfo->ipAddress = $clientIp;
     $guestinfo->userAgent = $userAgent;
     $guestinfo->country = $ipData->country;
     $guestinfo->area = $ipData->area;
     $guestinfo->region = $ipData->region;
     $guestinfo->city = $ipData->city;
     if ($guestinfo->save()) {
         $Status = '保存成功';
     } else {
         $Status = '保存失败';
     }
     var_dump($Status);
     return $Status;
 }
Beispiel #4
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //
     /* 循环删除
        for($i=0; $i<(count($this->id)); $i++)
        {
            $guestinfo = Guestinfo::findOrFail($this->id[$i]);
            $guestinfo->delete();
        }
         */
     try {
         Guestinfo::destroy($this->id);
     } catch (Exception $e) {
         return response($e->getMessage, 422);
     }
 }
Beispiel #5
0
 public function scopeAllGuestinfos()
 {
     $guestinfos = Guestinfo::orderBy('created_at', 'desc')->paginate(10);
     return $guestinfos;
 }