<?php

namespace App\Helpers;

use Illuminate\Support\Facades\Request;
use App\Models\LogActivity as LogActivityModel;

class LogActivity
{
	public static function addToLog($subject)
	{

		$role = Request::user()->roles;
		$user_id = Request::user()->id;
		$username = Request::user()->name;

		$log = [];
		$log['subject'] = $subject;
		$log['url'] = Request::fullUrl();
		$log['method'] = Request::method();
		$log['ip'] = Request::ip();
		$log['agent'] = Request::header('user-agent');
		$log['user_id'] = $user_id;
		$log['username'] = $username;
		$log['role'] = $role[0]->name;
		$log['type'] = 'admin';
		LogActivityModel::create($log);
	}

	public static function logActivityLists()
	{
		return LogActivityModel::latest()->get();
	}
}
