Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing array from AuthController to login view in Laravel 5

Am having a problem passing an array from Laravel's AuthController to auth.login view. What am trying to do is retrieve data from News model and send it to the view. I know how to use eloquent to retrieve data, passing from the controller to the view is my problem as I cannot see the how/where Laravel is rendering the view.

like image 779
shaNnex Avatar asked Nov 17 '25 23:11

shaNnex


1 Answers

Add an array as second parameter to the view method when returning it in the controller.

return view('greetings', ['name' => 'Victoria']); // in controller

Then in your view, you should be able to access the variable $name which should be equal to Victoria

var_dump($name); // in view

More in the documentation

like image 171
Avalanche Avatar answered Nov 19 '25 12:11

Avalanche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!