fridge_bites/apps/Admin/Controllers/IngredientRecipeRelController.php

50 lines
1.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Lycoreco\Apps\Admin\Controllers;
use Lycoreco\Apps\Recipes\Models\{
IngredientInRecipeModel,
IngredientModel
};
class IngredientRecipeRelController extends Abstract\AdminSingleController
{
protected $model_сlass_name = "Lycoreco\Apps\Recipes\Models\IngredientInRecipeModel";
protected $field_title = 'ingredient_name';
protected $object_router_name = 'admin:ing-cat-rel';
protected $verbose_name = "ingredient in recipe";
protected $component_widgets = ['the_recipe_ingredients_relation'];
protected $fields = array(
[
'model_field' => 'recipe_id',
'input_type' => 'number',
'dynamic_save' => false,
'input_label' => 'Recipe id',
'input_attrs' => ['required', 'disabled']
],
[
'model_field' => 'amount',
'input_type' => 'text',
'input_attrs' => ['required']
],
);
protected function get_model()
{
$model = parent::get_model();
if($this->context['is_new'])
$model->field_recipe_id = (int)$this->url_context['url_1'];
return $model;
}
public function __construct($is_new = false) {
parent::__construct($is_new);
$this->fields[] = [
'model_field' => 'ingredient_id',
'input_type' => 'select',
'input_label' => 'Ingedient',
'input_attrs' => ['required'],
'input_values' => IngredientModel::get_ing_values()
];
}
}