Хм, к сожалению, вы не можете передавать переменные из секции Markup
в Code
. Поскольку секция Code
в целом выполняется до Markup
, поэтому вы не можете этого сделать.
Кажется, вы используете компонент Record details
Builder, поэтому вы должны передавать :id
из URL
Решение 1 [использовать параметр]
function onStart() { // you can use onEnd as well
$frontId = $this->param('id'); // this will get :id param from url
// now slots variable are available in `Markup section`
$this["slots"] = Db::table('oblikovanje_izobrazevanja_vnos')->where('id', $frontId)->value('free_slots');
}
Решение 2 [вы можете использовать глобальный компонентный массив с его псевдоним, обязательно используйте onEnd ловушку жизненного цикла]
function onEnd () { // you must use onEnd as at this moment all components are initialized properly
// we can access component from $this->components with alias name and get its details
$frontId = $this->components['builderDetails']->record->id;
// now slots variable are available in `Markup section`
$this["slots"] = Db::table('oblikovanje_izobrazevanja_vnos')->where('id', $frontId)->value('free_slots');
}
Справочный снимок экрана
![enter image description here](https://i.stack.imgur.com/QqZZy.png)
если есть сомнения, прокомментируйте.