passing data to a view laravel

后端 未结 2 685
闹比i
闹比i 2021-01-26 15:16

Just getting to mvc frameworks and im trying to pass data to my view using blade template engine.

here\'s my routes file

Route::get(\'/\', \'PagesControl         


        
相关标签:
2条回答
  • 2021-01-26 15:23

    you can also pass data to view by using multiple with.

    return View::make('blog')->with('posts', $posts)->with('anotherPost',$anotherPost);
    


    you can always make multiple with or can pass values via array. whatever you think is best.

    0 讨论(0)
  • 2021-01-26 15:32

    Try this

    public function index() {
       $url = 'example.com';
       return view('index', ['url' => $url]); 
    }
    

    Initialize the variable and send it as a parameter to the view.

    0 讨论(0)
提交回复
热议问题