<?php

declare(strict_types=1);

namespace App\Http\Controllers\Backend\Pouzivatelia;

use App\Http\Controllers\Controller;
use App\Repositories\PouzivatelRepositoryContract;
use Illuminate\View\View;
use Spatie\Activitylog\Models\Activity;

/**
 * Class AkciePouzivatelovController
 */
final class AkciePouzivatelovController extends Controller
{
    private PouzivatelRepositoryContract $pouzivatelRepository;

    /**
     * AkciePouzivatelovController constructor.
     */
    public function __construct(PouzivatelRepositoryContract $pouzivatelRepository)
    {
        $this->pouzivatelRepository = $pouzivatelRepository;
    }

    public function index(int $pouzivatelId): View
    {
        $pouzivatel = $this->pouzivatelRepository->with('pracovisko')->find($pouzivatelId);
        $akcie = Activity::query()
            ->where('causer_id', $pouzivatel->id)
            ->orderByDesc('created_at')
            ->paginate();

        return view('pages.backend.pouzivatelia.akcie.index')
            ->withPouzivatel($pouzivatel)
            ->withAkcie($akcie);
    }
}
