Skip to content
Advertisement

Laravel db table can’t throw variable from controller to page file

Hello I have problem with variable.

JavaScript

Controller take data from db and return view. Next in web.php Routing throw variable from Controller to page file

Controller Code

PHP

view page code

PHP

And web.php Route

Route::resource(‘Pages/home’, ‘NewsController’);

How can I fix this problem

Advertisement

Answer

You pass it to the view as $Pages instead of $data_news.
The first parameter for the with function is the variable name

JavaScript

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement