How do I pass a variable to the layout using Laravel' Blade templating?

后端 未结 11 1999
猫巷女王i
猫巷女王i 2021-01-30 03:30

In Laravel 4, my controller uses a Blade layout:

class PagesController extends BaseController {
    protected $layout = \         


        
11条回答
  •  盖世英雄少女心
    2021-01-30 04:15

    just try this simple method: in controller:-

     public function index()
       {
            $data = array(
                'title' => 'Home',
                'otherData' => 'Data Here'
            );
            return view('front.landing')->with($data);
       }
    

    And in you layout (app.blade.php) :

    {{ $title }} - {{ config('app.name') }} 
    

    Thats all.

提交回复
热议问题