Laravel 5 how to output the meta tags?

There is a main template that includes a place for the conclusion of the meta-tags and page title.
Each of the controllers (any page, be it news, articles, etc.) is shown via the model needs information, connect need view and displays this information - it's simple. If, say, we went inside the news, the Show method of the controller communicates to the view through the variable $news all the information about news. Including meta tags and title. I.e. $news->meta...
But, for example, the situation when the news is not set meta tags, in this case, you need to get meta tags by default. Of course, you can do it inside the controller of news, but because of the site-many, will not be the same in each controller to register the meta-tags by default, So it begs the question: how to organize the output of the meta tags so that where in one place they should be assigned a value by default, and then have controllers in the case of meta tags to appear on the page information, would replace these meta tags by default relevant.

And ideally to do so is to create a separate controller, which would be responsible for the formation of meta-tags, regardless of which section you are in. And in the template be deduced these meta-tags like this { meta::showMetaTags }
I.e. this controller would receive information about the current section would take from the database the desired data and outputted to the template.

Anyone tell me how to do it?
July 8th 19 at 17:11
2 answers
July 8th 19 at 17:13
https://laravel.com/docs/5.2/views#view-composers
or view()->share()

Read, choose.
If I understand correctly, the share intended for installation you can access variables inside of views. This is very useful, thanks for the tip, but I still have a question. I think I have a slightly different case. I need to inside the controller, which takes the content from the database and displays on the page (for example, the same news), I had the opportunity to access one property that contains meta tags by default. I got the news from the database, took it meta tags if meta tags are empty, take them out of this property with the default tags. So how to organize such a scheme to the inside of all the controllers had the opportunity to access this property? - Liam.Mosciski commented on July 8th 19 at 17:16
my answer was caksusa the last paragraph of the question.
"And ideally to do so is to create a separate controller, which would be responsible for the formation of meta-tags, regardless of which section you are in."

This is done using view composers - nickolas commented on July 8th 19 at 17:19
July 8th 19 at 17:15
I'm just in the layout.blade prescribed <title>@yield('title', 'Default value')</title>
If the child template does not set section 'title' is displayed 'Default value'.
Where do you store Default value? - Liam.Mosciski commented on July 8th 19 at 17:18
: Generally to store all SEO-shnyh attributes I have a separate class with a configuration file. It works something like this:
Seo::get('article.show.title', ['name' => $article->name']')
Hands do not reach to make the package and put. - nickolas commented on July 8th 19 at 17:21
: and as your Seo method::get know from which table to retrieve data? After all, you pass in name only the name of the specific recording, as I understand it. And what is this record - news, articles, directory, etc. - is unknown...

And one more question. You this string Seo::get... cause right in the view? - Liam.Mosciski commented on July 8th 19 at 17:24

Find more questions by tags Laravel