We can pass data to view simply from controller or from web.php as well here is a example
Route::get('/', function () { return view('greeting', ['name' => 'Jones']); });
Now in case you need to pass data from controller. it will look like this
Route::get('/', SomeController@someFunction);
Inside "Some Controller" here we have someFunction looks like this
public function someFunction(){ return view('greeting', ['name' => 'Jones']); } or public function someFunction(){ return view('greeting')->with('posts' , $posts); }
Hope this helps