I have a form to create components
for a page
, and this field can only be shown when the user is editing the page
, how do I check the route on the laravel?
It would be an if () {}
inside the field.
protected function formFields(EloquentModel $model): array
{
$request = app('request');
/* @var $website Site */
$website = $request->route('website');
$websitePages = SiteContent::query()
->where('site_id', $website->getKey());
$inputs = [];
$inputs [] = [
'name' => 'content',
'label' => 'Conteúdo',
'type' => 'view',
'view' => 'website.pages.field-components'
];
return $inputs;
}
if ($model->getKey()) {
$inputs [] = [
'name' => 'content',
'label' => 'Conteúdo',
'type' => 'view',
'view' => 'website.pages.field-components'
];
}
I solved it that way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.