<?php

namespace App\Components\Admin\Users;

use App\Models\User\User;
use Livewire\Component;
use Livewire\WithPagination;

class UserHistory extends Component {
    use 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),
        ]);
    }
}
