<?php

namespace App\Components\Admin\Users;

use App\Models\User\User;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
use Livewire\WithPagination;

class UserHistory extends Component {
    use AuthorizesRequests, WithPagination;

    public User $user;

    public function mount(User $user) {
        $this->authorize('viewHistory', $user);
    }

    public function render() {
        return view('components.admin.users.user-history', [
            'history' => \App\Models\History::where('user_id', $this->user->id)
                ->with('owner')
                ->latest()
                ->paginate(20),
        ]);
    }
}
