dimanche 26 février 2017

How to recording the user's device in laravel

how to add data device (tablet, mobile, desktop) if users access to one of the devices when logged on, then the data was recorded.

i use packages jenssegers/agent

table device having column: device_name, date

i try, but can't record in table

this my code in LoginController.php

   public function check(){
      $agent = new Agent();
      $dt = Carbon::now();

      if ( $agent->isDesktop() == true )
      {
        DB::table('device')->insert([
           ['device_name' => 'desktop', 'tgl' => $dt->toDateString()],
       ]);
      }

      elseif ($agent->isTablet() == true) {
        DB::table('device')->insert([
           ['device_name' =>'tablet', 'tgl' => $dt->toDateString()],
       ]);
      }

      elseif ($agent->isMobile() == true) {
        DB::table('device')->insert([
           ['device_name' => 'mobile', 'tgl' => $dt->toDateString()],
       ]);
     }

    }

please help me, thank you very much...



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l1QIXE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire