title: How to recording the user's device in laravel
body: <p>how to add data device (tablet, mobile, desktop) if users access to one of the devices when logged on, then the data was recorded.</p>
  
  <p>i use packages jenssegers/agent</p>
  
  <p>table <strong>device</strong> having column: device_name, date</p>
  
  <p>i try, but can't record in table</p>
  
  <p>this my code in LoginController.php</p>
  
  <pre><code>   public function check(){
        $agent = new Agent();
        $dt = Carbon::now();
  
        if ( $agent-&gt;isDesktop() == true )
        {
          DB::table('device')-&gt;insert([
             ['device_name' =&gt; 'desktop', 'tgl' =&gt; $dt-&gt;toDateString()],
         ]);
        }
  
        elseif ($agent-&gt;isTablet() == true) {
          DB::table('device')-&gt;insert([
             ['device_name' =&gt;'tablet', 'tgl' =&gt; $dt-&gt;toDateString()],
         ]);
        }
  
        elseif ($agent-&gt;isMobile() == true) {
          DB::table('device')-&gt;insert([
             ['device_name' =&gt; 'mobile', 'tgl' =&gt; $dt-&gt;toDateString()],
         ]);
       }
  
      }
  </code></pre>
  
  <p>please help me, thank you very much...</p>