Retrieving single recipe
This commit is contained in:
parent
11471894f7
commit
892e42ba33
@ -29,4 +29,15 @@ class RecipesController extends Controller
|
|||||||
|
|
||||||
return response()->json(['success' => true, 'data' => ['recipes' => $recipes]], 200);
|
return response()->json(['success' => true, 'data' => ['recipes' => $recipes]], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get(int $id)
|
||||||
|
{
|
||||||
|
$recipe = $this->recipesRepository->get($id);
|
||||||
|
|
||||||
|
if(empty($recipe['name'])){
|
||||||
|
return response()->json(['success' => true, 'error' => 'Recipe not found'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'data' => ['recipe' => $recipe]], 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,5 @@ interface RecipesRepositoryInterface
|
|||||||
{
|
{
|
||||||
public function create(Collection $data);
|
public function create(Collection $data);
|
||||||
public function paginate(array $filters);
|
public function paginate(array $filters);
|
||||||
|
public function get(int $id);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ Route::prefix('product')->group(function () {
|
|||||||
Route::prefix('recipe')->group(function () {
|
Route::prefix('recipe')->group(function () {
|
||||||
Route::post('/', 'RecipesController@add')->middleware(['jwt.auth']);
|
Route::post('/', 'RecipesController@add')->middleware(['jwt.auth']);
|
||||||
Route::get('/', 'RecipesController@index');
|
Route::get('/', 'RecipesController@index');
|
||||||
|
Route::get('/{id}', 'RecipesController@get');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::post('calculate', 'ProductsController@calculate');
|
Route::post('calculate', 'ProductsController@calculate');
|
||||||
|
Loading…
Reference in New Issue
Block a user