41 lines
870 B
PHP
41 lines
870 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
use App\Container;
|
||
|
use Illuminate\Http\Request;
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
}
|