<?php

namespace App\Livewire\Admin\Settings\Logs;

use Livewire\Component;
use Livewire\Attributes\Computed;
use Livewire\WithPagination;
use Spatie\Activitylog\Models\Activity;

class ShowLogs extends Component
{
    use WithPagination;

    public $paginate = 25;

    public function mount()
    {
        $storedPaginate = session('paginate', $this->paginate);
        $this->paginate = $storedPaginate;
    }

    public function updatedPaginate($value)
    {
        session(['paginate' => $value]);
    }

    #[Computed()]
    public function logs()
    {
        return Activity::orderByDesc('created_at')->paginate($this->paginate);
    }

    public function render()
    {
        return view('livewire.admin.settings.logs.show-logs');
    }
}
