未定义变量php laravel 5.4

未定义变量php laravel 5.4,php,laravel,Php,Laravel,我总是犯同样的错误 未定义变量:我的刀刃上的剧院,第14行 这是我的addcine.blade.php第14行 @foreach ($theaters as $theater) <option value="{{ $theater->name }}"/> @endforeach 我的路线呢 Route::get('addcinema','AddCinemaController@index'); }); 您没有将$theaters值发送到视图 您没有将$the

我总是犯同样的错误

未定义变量:我的刀刃上的剧院,第14行

这是我的addcine.blade.php第14行

@foreach ($theaters as $theater)
    <option value="{{ $theater->name }}"/>
    @endforeach
我的路线呢

Route::get('addcinema','AddCinemaController@index');
});
您没有将
$theaters
值发送到视图

您没有将
$theaters
值发送到视图,

它应该是:

return view('schedules.addcine', compact('theaters'));
compact('theaters')
正是这样做的:

return view('schedules.addcine', ['theaters' => $theaters]);
应该是:

return view('schedules.addcine', compact('theaters'));
compact('theaters')
正是这样做的:

return view('schedules.addcine', ['theaters' => $theaters]);

您正在控制器中发送
name
而不是
theaters

public function index(){

$theaters = Theater::all();

return view('schedules.addcine', compact('name'));
public function index(){

$theaters = Theater::all();

return view('schedules.addcine', compact('theaters'));

您正在控制器中发送
name
而不是
theaters

public function index(){

$theaters = Theater::all();

return view('schedules.addcine', compact('name'));
public function index(){

$theaters = Theater::all();

return view('schedules.addcine', compact('theaters'));

您需要返回要查看的
$thaters
变量,以便在那里使用它

像这样返回:

return view('schedules.addcine', compact('theaters'));

您需要返回要查看的
$thaters
变量,以便在那里使用它

像这样返回:

return view('schedules.addcine', compact('theaters'));

哦非常感谢你。这样愚蠢的错误。原谅我的无知哦。非常感谢你。这样愚蠢的错误。请原谅我的无知('schedules.addcine',compact('theaters');返回视图('schedules.addcine',compact('theaters');