What is the with function in laravel framework ?!, Online ......

Source: Internet
Author: User
In this laravel getting started tutorial, I can see this writing: {code ...} the withPages () function is not rooted in laravel. I searched it on Google and did not find the answer. according to my guess, in my opinion, pages after withPages are mapped to the blade template... in this laravel getting started tutorial, I can see the following method:


  withPages(Page::all());    }}

HereWithPages ()The function is not rooted in laravel. I searched it on Google and found no answer. according to my guess, in my opinion, pages after withPages are a data variable mapped to the blade template ($ pages). However, I can see that this method is not found in the laravel document.with('name', 'Victoria');In this way, which of the following friends knows what is going on? can you give me some information? Tell me what's going on? Very urgent.

Reply content:

In this laravel getting started tutorial, I can see the following method:


  withPages(Page::all());    }}

HereWithPages ()The function is not rooted in laravel. I searched it on Google and found no answer. according to my guess, in my opinion, pages after withPages are a data variable mapped to the blade template ($ pages). However, I can see that this method is not found in the laravel document.with('name', 'Victoria');In this way, which of the following friends knows what is going on? can you give me some information? Tell me what's going on? Very urgent.

Dynamic View assignment!

The following are equivalent values:

view('home')->withPages(Page::all());view('home')->with('pages', Page:all());

In the previous chapter: Laravel 5 series Getting Started Tutorial (2) [Laravel tutorial most suitable for Chinese users] The following is a comment:

WithPages is used to query Pages tables.

This article was published last year and is old. you can refer to the new tutorial: 2016 Laravel series Getting Started Tutorial (1)
Laravel College is also a good tutorial website.

You can understand this method as syntactic sugar.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.