fridge_bites/apps/Admin/components.php

83 lines
1.9 KiB
PHP

<?php
use Lycoreco\Apps\Users\Models\{
UserModel,
BanlistModel
};
use Lycoreco\Apps\Recipes\Models\{
RecipeModel,
IngredientModel,
IngredientInRecipeModel
};
function the_admin_header(string $title)
{
require_once APPS_PATH . '/Admin/Templates/components/admin-header.php';
}
function the_admin_footer()
{
require_once APPS_PATH . '/Admin/Templates/components/admin-footer.php';
}
/*
* Widgets in the single object page
*/
function the_user_banlist(UserModel $user)
{
$banlist = BanlistModel::filter(array(
[
'name' => 'obj.user_id',
'type' => '=',
'value' => $user->get_id()
]
),
['-obj.end_at']);
require APPS_PATH . '/Admin/Templates/widgets/user_banlist.php';
}
function the_recipe_author(RecipeModel $recipe)
{
$author = UserModel::get(array(
[
'name' => 'obj.id',
'type' => '=',
'value' => $recipe->field_author_id
]
));
require APPS_PATH . '/Admin/Templates/widgets/recipe_author.php';
}
function the_recipe_ingredients(RecipeModel $recipe)
{
$ingredients = IngredientInRecipeModel::filter(array(
[
'name' => 'obj.recipe_id',
'type' => '=',
'value' => $recipe->get_id()
]
));
require APPS_PATH . '/Admin/Templates/widgets/ingredients_in_recipe.php';
}
function the_recipe_ingredients_relation(IngredientInRecipeModel $relation)
{
$ingredient = IngredientModel::get(array(
[
'name' => 'obj.id',
'type' => '=',
'value' => $relation->field_ingredient_id
]
));
$recipe = RecipeModel::get(array(
[
'name' => 'obj.id',
'type' => '=',
'value' => $relation->field_recipe_id
]
));
require APPS_PATH . '/Admin/Templates/widgets/ingredients_in_recipe_relation.php';
}