未定义变量:vaccine\u feed(视图:C:\xampp\htdocs\webapp\resources\views\addstock.blade.php)

未定义变量:vaccine\u feed(视图:C:\xampp\htdocs\webapp\resources\views\addstock.blade.php),php,laravel,Php,Laravel,当试图将数据从控制器传递到数据库中的视图时,我得到了一个未定义的变量 Part of my Controller: public function index() { $vaccine_feed = Vaccines::All(); return view('welcome', [ 'vaccines' => $vaccines, 'user' => $user, 'vaccine_fee

当试图将数据从控制器传递到数据库中的视图时,我得到了一个未定义的变量

Part of my Controller:
public function index()
    {
      $vaccine_feed = Vaccines::All();
        return view('welcome', [
          'vaccines' => $vaccines,
          'user' => $user,
          'vaccine_feed' => $vaccine_feed
        ]);
    }




View:

foreach($vaccine_feed as $vaccines ) {

}
如果有帮助的话,我已经在下面添加了我的路线

Auth::routes();
Route::get('/', function () {
    return view('welcome');
});
Route::get('/home', 'HomeController@index')->name('home');

Route::get('/logout', function () {
    Auth::logout();
    Session::flush();
    return view('welcome');
});


Route::get('/addstock', 'AddForm@getStockForm');
Route::post('/addstock', 'AddForm@postStockForm');

在控制器中尝试dd($vaccine_feed)(返回之前),看看它是否返回任何内容。

您是否将addstock.blade.php包含在欢迎模板中。因为该视图具有不同的范围,您可能希望将$vaccine\u提要传递到您所在的任何地方。

它仍然给我相同的东西,未定义的变量,它看起来不像是触发器。我的addstock与welcome blade的路线不同,我尝试将其添加到欢迎刀片,但我得到了相同的错误我添加了我的路线,如果这有帮助的话