/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $ingredient = Ingredient::find($id); $ingredient->delete(); return Redirect::to('ingredient'); }
function InsertIngredient() { require_once "models/Ingredient.php"; $newIngredient = new Ingredient(); $name = $_POST["name"]; Ingredient::insert($dbh, $name); $newIngredient->find($dbh, $name); return json_encode($newIngredient); }
public function show($id) { if ($id == 0) { $ingredients = Ingredient::all(); foreach ($ingredients as $key => $item) { $ingredients[$key]['type'] = \App\Type::find($item->type_id); } return response()->json(['ingredients' => $ingredients]); } else { $aux = \App\Type::all(); $types = $this->getTypes($aux); $ingredient = Ingredient::find($id); return response()->json(['ingredient' => $ingredient, 'types' => $types]); } }
<?php require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'trest_init.php'); require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'Sandwich.php'); require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'Ingredient.php'); header('Content-Type: application/json'); $id = @$_GET['id']; $id = (int) $id; if ($id) { $result = Ingredient::find($id); } else { $result = Ingredient::findAll(); } echo json_encode($result);