<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\CreateInviteCodesRequest;
use App\Services\InviteCodeService;
use Illuminate\Http\RedirectResponse;

class InviteCodeController extends Controller
{
    public function store(CreateInviteCodesRequest $request, InviteCodeService $inviteCodes): RedirectResponse
    {
        $created = $inviteCodes->createCodes(
            (int) $request->integer('quantity'),
            $request->user(),
        );

        return back()->with('status', sprintf('Создано инвайт-кодов: %d.', $created->count()));
    }
}
