How to implement Laravel 4 Partial Views - Binding data to partial views

前端 未结 3 1202
心在旅途
心在旅途 2021-01-06 07:11

I am debating whether I should use Laravel to build an online store.

Requirement - Show a shopping cart in sidebar with product listing in main area. i need to bind

相关标签:
3条回答
  • 2021-01-06 07:47

    Make a composers.php file in your app/ directory and include it via app/start/global.php. In this file, do the View::composer calls (you do not need to put them inside App::before).

    Move the composer classes into a new app/composers/ directory and add the directory to the autoloader in your composer.json.

    Other than that, your use of composers is correct.

    0 讨论(0)
  • 2021-01-06 07:48

    for me create a abstract class ShopController extends BaseController

    and in constructor() write View::composer

    and you can use DB::table('products')->remember(100)->get(); vs all() for the cache

    0 讨论(0)
  • 2021-01-06 07:52

    You can simply do

    @include('partials.products', array('data'=>'here'))
    
    0 讨论(0)
提交回复
热议问题