<?php

namespace Modules\Main\Http\Controllers\Company;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Main\Models\Company\Company;
use Modules\Main\Models\Company\CompanyType;
use Modules\Main\Models\City;

class CreateCompanyFormController extends Controller
{
    /**
     * Handle the incoming request.
     */
    public function __invoke(Request $request)
    {
        $type = false;
        $city_id = false;
        if ($request->has('type'))
        {
            $request->enum('type', CompanyType::class);
            $type = $request->type;
        }
        ;
        if ($request->has('city_id'))
        {
            $city_id = $request->city_id;
        }
        ;
        return view('main::company.create', [
            'type'       => $type,
            'city_id'    => $city_id,
            'typesList'  => CompanyType::cases(),
            'citiesList' => City::all()
        ]);
    }
}
