Added City model, resource and its API.
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API\v2;
|
||||
|
||||
use App\Http\Requests\StoreCityRequest;
|
||||
use App\Http\Requests\UpdateCityRequest;
|
||||
use App\Models\City;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\API\v2\CityResource;
|
||||
use App\Http\Resources\API\v2\CityCollection;
|
||||
|
||||
class CityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
return new CityCollection(City::all());
|
||||
}
|
||||
|
||||
public function selectCity(Request $request)
|
||||
{
|
||||
$name = $request->input('name');
|
||||
$uuid = $request->input('uuid');
|
||||
|
||||
// Process the received name and uuid as required
|
||||
|
||||
// Return a response
|
||||
return response()->json([
|
||||
'message' => 'City selected successfully',
|
||||
'name' => $name,
|
||||
'uuid' => $uuid,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(StoreCityRequest $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(City $city)
|
||||
{
|
||||
return new CityResource($city);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(City $city)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateCityRequest $request, City $city)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(City $city)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user