c3lf-system-3/app/Http/Controllers/ItemController.php
Jan Felix Wiebe 194a0a81e0 added items
2019-11-15 22:26:54 +01:00

40 lines
No EOL
804 B
PHP

<?php
namespace App\Http\Controllers;
use App\Item;
use Illuminate\Http\Request;
class ItemController extends Controller
{
public function showAllEvents()
{
return response()->json(Item::all());
}
public function showOneEvent($id)
{
return response()->json(Item::find($id));
}
public function create(Request $request)
{
$item = Item::create($request->all());
return response()->json($item, 201);
}
public function update($id, Request $request)
{
$item = Item::findOrFail($id);
$item->update($request->all());
return response()->json($item, 200);
}
public function delete($id)
{
Item::findOrFail($id)->delete();
return response('Deleted Successfully', 200);
}
}