<?php

namespace App\Http\Controllers;

use App\Models\Audit;
use Illuminate\Http\Request;
use App\Models\Company;


class AuditController extends Controller
{
    public function index(Request $request)
    {

       $user = auth()->user();
    if ($user->hasRole('super-admin')) {
            /*$audits = Audit::latest()->get();*/
               $audits = Audit::with('user')
            ->latest()
            ->paginate(20);
        } else {

           $audits = Audit::where('company_id', $user->company_id)
            ->latest()
            ->paginate(20);
            
        
        }
      
        return view('auditoria.index', compact('audits'));
    }
}
