<?php

declare(strict_types=1);

namespace App\Http\Controllers\Backend\Pouzivatelia;

use App\Http\Controllers\Controller;
use App\Repositories\PouzivatelRepositoryContract;
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;
    }

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

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