<?php

namespace App\Http\Middleware;

use Closure;
use App\Helpers\LogActivity;

class SystemLog
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $data = '';

        switch ($request->path()) {
            case 'index':
                $data = 'تم فتح واجهة عرض المنتجات للمورد'.'<br>'.json_encode($request->all());
                break;
            
            default:
                # code...
                break;
        }
       
        LogActivity::addToLog($data);

        return $next($request);
    }
}
