<?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
 *
 * @package App\Http\Controllers\Backend\Pouzivatelia
 */
final class AkciePouzivatelovController extends Controller
{
    /**
     * @var \App\Repositories\PouzivatelRepositoryContract
     */
    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);
    }
}
