c3lf-system-3/app/Http/Controllers/ItemController.php

40 lines
804 B
PHP
Raw Normal View History

2019-11-15 21:26:54 +00:00
<?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);
}
}