StocksNew/Modules/Admin/app/Http/Controllers/CityController.php

84 lines
1.9 KiB
PHP
Raw Normal View History

2024-08-27 12:03:06 +00:00
<?php
namespace Modules\Admin\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Admin\Repositories\CityRepository;
class CityController extends Controller
{
private $cityRepository;
public function __construct(CityRepository $cityRepository)
{
$this->cityRepository = $cityRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'City List';
$data['cityLists'] = $this->cityRepository->findAll();
return view('admin::cities.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create City';
$data['editable'] = false;
return view('admin::cities.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$this->cityRepository->create($request->all());
return redirect()->route('city.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('admin::cities.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit City';
$data['editable'] = true;
$data['city'] = $this->cityRepository->getCityById($id);
return view('admin::cities.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$this->cityRepository->update($id, $request->all());
return redirect()->route('city.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
}