-
-
Couldn't load subscription status.
- Fork 146
How to generate such a code? #84
Answered
by
dg
svfolderOld
asked this question in
Q&A
-
Hello.
Thank you very much for your work!
Can you tell me how to generate such a code?
[
'attribute' => 'brand_id',
'filter' => $searchModel->brandList(),
'value' => function (BrandAliasAssignment $model) {
return $model->getBrand()->one()->name;
},
],
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
dg
Jul 5, 2021
https://fiddle.nette.org/nette/#6c8292c389
$closure = new Nette\PhpGenerator\Closure; $closure->setBody('return $model->getBrand()->one()->name;'); $closure->addParameter('model')->setType(BrandAliasAssignment::class); echo (new Nette\PhpGenerator\Dumper)->dump([ 'attribute' => 'brand_id', 'filter' => new Nette\PhpGenerator\PhpLiteral('$searchModel->brandList()'), 'value' => new Nette\PhpGenerator\PhpLiteral((string) $closure), ]);
Replies: 1 comment
-
https://fiddle.nette.org/nette/#6c8292c389
$closure = new Nette\PhpGenerator\Closure; $closure->setBody('return $model->getBrand()->one()->name;'); $closure->addParameter('model')->setType(BrandAliasAssignment::class); echo (new Nette\PhpGenerator\Dumper)->dump([ 'attribute' => 'brand_id', 'filter' => new Nette\PhpGenerator\PhpLiteral('$searchModel->brandList()'), 'value' => new Nette\PhpGenerator\PhpLiteral((string) $closure), ]);
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Answer selected by
svfolderOld
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment