<?php

declare(strict_types=1);

namespace App\Repositories\Eloquent;

use App\Models\Pouzivatel\Pouzivatel;
use Prettus\Repository\Eloquent\BaseRepository;
use App\Repositories\PouzivatelRepositoryContract;

/**
 * Class PouzivatelRepository
 *
 * @package App\Repositories\Eloquent
 */
final class PouzivatelRepository extends BaseRepository implements PouzivatelRepositoryContract
{
    /**
     * @return string
     */
    public function model()
    {
        return Pouzivatel::class;
    }

    /**
     * @param int    $userId
     * @param string $token
     *
     * @return void
     */
    public function saveNotificationToken(int $userId, string $token): Pouzivatel
    {
        /** @var \App\Models\Pouzivatel\Pouzivatel $user */
        $user = $this->find($userId);
        $user->setAttribute('notification_token', $token);
        $user->save();

        return $user->refresh();
    }
}
