R
R
Rodion2018-06-16 09:55:10
Laravel
Rodion, 2018-06-16 09:55:10

How to pass a value to TITLE when filtering?

The following is passed to the title:

@section('title', $category ? $category->seo_title : '')

If the category is such and such, then the title from the seo_title field The
question for the teapot is the following: How can I transfer {{$city? ''.$city->name : ''}}?
Can't figure out how to pass multiple properties?
@section('title', 'Категория - '.$category->seo_title. ' - город '.$city->name. ' - город' .$city->name)

So it displays what I need, but if the city is not selected in the filter, it gives an error ...
I understand that I need to form a "request" - like: what group? - display and which city - display, but I don’t understand how to do this in the code ...
@section('title', $category ? .$category->seo_title. $city ? .$city->name. : '')

Help me please...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-06-16
@azmarin

Move the title formation logic into the controller.
Do not shove everything in one line, do it consistently so as not to get confused, like

$title = '';
$title .= $category ? 'Категория - ' . $category->seo_title : '';
$title .= $city ? 'Город - ' . $city->name : '';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question