<?php

namespace Modules\Admin\Http\Controllers;


use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\CityManager\Models\CityManager;
use Modules\Main\Models\City;
class AdminCityManagersController extends Controller
{
    public function index(Request $request)
    {
        return view('admin::cities.managers', [
            'managers' => CityManager::with(['user', 'city'])->get(),
            'cities'   => City::all(),
            'filter'   => $request->filter
        ]);
    }

    public function create(Request $request)
    {
        $manager = CityManager::firstOrCreate($request->only(['user_id', 'city_id']));
        return to_route('admin.cities.managers');
    }
    public function delete(Request $request, CityManager $manager)
    {
        $manager->delete();
        return to_route('admin.cities.managers');
    }
}
