<?php

namespace App\Http\Livewire;

use App\Models\System_log;
use Livewire\Component;

class NavLogs extends Component
{
    public $logs = [];
    public $date;

    public function fetch(){
        if ($this->date === null) {
            return System_log::with(['users'])->latest()->get();
        } else {
            return System_log::where('dated_on', $this->date)->with(['users'])->latest()->get();
        }
        
        
    }
    
    public function render()
    {
        $this->logs = $this->fetch();
        return view('livewire.nav-logs');
    }
}
