Compare commits
No commits in common. "3e9fdd36bb666d7945ce923149fc90d8be5cb5e5" and "f588e5f608b4ca9682b09be44ac83e3944dc52cc" have entirely different histories.
3e9fdd36bb
...
f588e5f608
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Lycoreco\Apps\Recipes\Models\{
|
||||
IngredientModel,
|
||||
RecipeModel,
|
||||
RecipeUserMenu
|
||||
};
|
||||
@ -31,8 +30,12 @@ function ajax_search()
|
||||
$result = array();
|
||||
|
||||
$recipes = RecipeModel::filter(
|
||||
count: 5,
|
||||
search: $search_query
|
||||
array(),
|
||||
array(),
|
||||
5,
|
||||
'AND',
|
||||
0,
|
||||
$search_query
|
||||
);
|
||||
|
||||
$result['count'] = count($recipes);
|
||||
@ -94,44 +97,3 @@ function ajax_usermenu()
|
||||
$result['success'] = 'You have successfully added the recipe to your menu.';
|
||||
return $result;
|
||||
}
|
||||
function ajax_create_ingredient()
|
||||
{
|
||||
$ingredient_name = $_POST['name'] ?? null;
|
||||
$ingredient_unit = $_POST['unit'] ?? null;
|
||||
|
||||
if (!CURRENT_USER) {
|
||||
return get_ajax_error('You are not authorized', 401);
|
||||
}
|
||||
if (!isset($ingredient_name)) {
|
||||
return get_ajax_error("Missing 'name' parameter.", 400);
|
||||
}
|
||||
if (!isset($ingredient_unit)) {
|
||||
return get_ajax_error("Missing 'unit' parameter.", 400);
|
||||
}
|
||||
|
||||
$ingredient = new IngredientModel();
|
||||
$ingredient->field_name = $ingredient_name;
|
||||
$ingredient->field_unit_name = $ingredient_unit;
|
||||
$ingredient->save();
|
||||
|
||||
$result = array();
|
||||
$result['success'] = 'You have successfully added new ingredient';
|
||||
return $result;
|
||||
}
|
||||
function ajax_search_ingredient()
|
||||
{
|
||||
$search_query = $_POST['query'] ?? null;
|
||||
if (!isset($search_query)) {
|
||||
return get_ajax_error("Missing 'query' parameter.", 400);
|
||||
}
|
||||
$result = array();
|
||||
|
||||
$ingredients = IngredientModel::filter(
|
||||
count: 5,
|
||||
search: $search_query
|
||||
);
|
||||
$result['count'] = count($ingredients);
|
||||
$result['result'] = $ingredients;
|
||||
|
||||
return $result;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user