<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Helpers\UserSystemInfo;
use Illuminate\Support\Facades\DB;
use App\Models\User;

class UserSystemInfoController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()

    {
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
    function getusersysteminfo()
    {
        //  dd('test');
        $getip = UserSystemInfo::get_ip();
        $getbrowser = UserSystemInfo::get_browsers();
        $getdevice = UserSystemInfo::get_device();
        $getos = UserSystemInfo::get_os();

        return view('user.loghistory', [
            'getip' => $getip,
            'getbrowser' => $getbrowser,
            'getdevice' => $getdevice,
            'getos' => $getos

        ]);
    }

    function userLogInfo(Request $request, $id)
    {
        $userinfo = User::find($id);
        //dd($userinfo->email);
        $list = DB::table('user_log_details')
                         ->where('email', $userinfo->email)
                         ->orderBy('id', 'desc')
                         ->get();

        return view('user.loghistory', [
            'list' => $list
        ]);
    }
}
