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

46 lines
919 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
{
2019-11-30 12:47:54 +00:00
public function showAllItems()
2019-11-15 21:26:54 +00:00
{
return response()->json(Item::all());
}
2019-11-30 12:47:54 +00:00
public function searchAllItems()
{
return response()->json(Item::all()); //TODO actually search
}
public function showOneItem($id)
2019-11-15 21:26:54 +00:00
{
return response()->json(Item::find($id));
}
public function create(Request $request)
2019-11-30 12:47:54 +00:00
{
2019-11-15 21:26:54 +00:00
$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);
}
2019-11-30 12:47:54 +00:00
}