refactor items table
This commit is contained in:
parent
836fb96f42
commit
8ab469e017
4 changed files with 56 additions and 22 deletions
|
@ -38,7 +38,7 @@ class ItemController extends Controller
|
|||
public function showOneItem($event, $id)
|
||||
{
|
||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||
return response()->json(Item::byEvent($eid)->where('item_uid', '=', $id)->first());
|
||||
return response()->json(Item::byEvent($eid)->where('uid', '=', $id)->first());
|
||||
}
|
||||
|
||||
public function create($event, Request $request)
|
||||
|
@ -46,8 +46,6 @@ class ItemController extends Controller
|
|||
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||
$newitem = $request->except(['dataImage']);
|
||||
$newitem['eid'] = "".$eid;
|
||||
$newitem['wo'] = "";
|
||||
$newitem['wann'] = "";
|
||||
$item = Item::create($newitem);
|
||||
|
||||
if ($request->get('dataImage')) {
|
||||
|
@ -69,7 +67,7 @@ class ItemController extends Controller
|
|||
public function update($event, $id, Request $request)
|
||||
{
|
||||
$eid = Event::where('slug', $event)->first()->eid;
|
||||
$item = Item::where('eid', $eid)->where('item_uid', $id)->first();
|
||||
$item = Item::where('eid', $eid)->where('uid', $id)->first();
|
||||
$item->update($request->except(['file', 'box', 'dataImage']));
|
||||
|
||||
if($request->get('returned')===true){
|
||||
|
@ -89,13 +87,13 @@ class ItemController extends Controller
|
|||
$item['file'] = $hash;
|
||||
}
|
||||
}
|
||||
return response()->json(Item::find($item['item_uid']), 200);
|
||||
return response()->json(Item::find($item['uid']), 200);
|
||||
}
|
||||
|
||||
public function delete($event, $id)
|
||||
{
|
||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||
Item::where('eid', $eid)->where('item_uid', $id)->first()->delete();
|
||||
Item::where('eid', $eid)->where('uid', $id)->first()->delete();
|
||||
return response()->json(array("status"=>'Deleted Successfully'), 200);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue