コード例 #1
0
ファイル: MockVisitors.php プロジェクト: retailone/retailone
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $now = Carbon::parse('yesterday')->startOfDay();
     for ($i = 0; $i < 1000; $i++) {
         DB::table((new Visitor())->getTable())->lockForUpdate()->insert(['type' => rand(0, 1) ? 'out' : 'in', 'device_id' => Device::first()->id, 'created_at' => $now->addHour(), 'updated_at' => $now]);
     }
 }
コード例 #2
0
 public function record(Request $request)
 {
     $this->validate($request, ['uuid' => 'required|exists:devices']);
     $date = Carbon::create();
     DB::table((new Visitor())->getTable())->lockForUpdate()->insert(['device_id' => Device::where('uuid', $request->get('uuid'))->first()->id, 'type' => $request->get('type') ? 'in' : 'out', 'created_at' => $date, 'updated_at' => $date]);
     return $this->response()->created();
 }
コード例 #3
0
 public function show(Datatables $datatables, $id)
 {
     $store = Store::findOrFail($id);
     $device = Device::findOrFail($id);
     if ($datatables->getRequest()->ajax()) {
         return $datatables->of(Visitor::select(['type', 'device_id', 'created_at'])->where('device_id', $device->id)->orderBy('created_at', 'desc'))->make(true);
     }
     $html = $datatables->getHtmlBuilder()->columns(['type', 'created_at']);
     return view('backend.admin.stores.show', compact('device', 'store', 'html'));
 }
コード例 #4
0
ファイル: DeviceSeeder.php プロジェクト: retailone/retailone
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $data = [['uuid' => 'DEVICE_1', 'device_type_id' => DeviceType::first()->id, 'store_id' => Store::first()->id, 'created_at' => Carbon\Carbon::create(), 'updated_at' => Carbon\Carbon::create()]];
     Device::insert($data);
 }