/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($location_id, $id) { $item = Item::find($id); if ($item->delete() === true) { $itemdesc = Itemdetail::where('item_id', $id)->first(); if ($itemdesc->delete() === true) { return response()->json(["Response" => "success"]); } else { return response()->json(["Response" => "fail"]); } } else { return response()->json(["Response" => "fail"]); } }
public function getcatitems($id) { $items = DB::table('maincards_cat_meta')->where('cat_id', '=', $id)->get(); $result = array(); if ($items === null) { return response()->json(["Response" => "No record"]); } else { foreach ($items as $item) { $thing = Item::find($item->item_id); $thingstuff = Itemdetail::where('item_id', $item->item_id)->first(); $data['id'] = $thing->id; $data['name'] = $thing->name; $data['description'] = $thingstuff->description; $data['price'] = $thingstuff->price; $data['item_type'] = $thingstuff->item_type; $result[] = $data; } return $result; } }