46 lines
No EOL
976 B
PHP
46 lines
No EOL
976 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Container;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* @group Container management
|
|
*
|
|
* APIs for creating, deleting, updating and viewing containers
|
|
*/
|
|
class ContainerController extends Controller
|
|
{
|
|
|
|
public function showAllContainers()
|
|
{
|
|
return response()->json(Container::all());
|
|
}
|
|
|
|
public function showOneContainer($id)
|
|
{
|
|
return response()->json(Container::find($id));
|
|
}
|
|
|
|
public function create(Request $request)
|
|
{
|
|
$container = Container::create($request->all());
|
|
|
|
return response()->json($container, 201);
|
|
}
|
|
|
|
public function update($id, Request $request)
|
|
{
|
|
$container = Container::findOrFail($id);
|
|
$container->update($request->all());
|
|
|
|
return response()->json($container, 200);
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
Container::findOrFail($id)->delete();
|
|
return response('Deleted Successfully', 200);
|
|
}
|
|
} |