ErrorException 未定义的变量
ErrorException Undefined variable
我有这样的按摩错误 ErrorException
未定义的变量:帖子(视图:C:\xampp\htdocs\TA\resources\views\petani\index.blade.php)。我该如何解决?
控制器:
public function index(){
$post = Desa::all();
return view('petani.index',compact ('desas'));
}
路线:
Route::get('petani', 'BiodataController@index');
指数:
<?php
$no = 1;
?>
@foreach ($posts as $post)
<td>{{$no++}}</td>
<td>{{$post->nama}}</td>
<td>
<button type="button" class="btn"><a href="{{ URL::to('coba/test/'.$post->id.'/edit') }}" >Edit</a></button>
{{ Form::open(['url' => 'coba/test/'.$post->id, 'method' => 'DELETE']) }}
{{ Form::button('delete', ['type' => 'submit', 'class' => 'btn']) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
而不是 compact('desas')
,输入 ['posts' => $post]
就可以了
我有这样的按摩错误 ErrorException 未定义的变量:帖子(视图:C:\xampp\htdocs\TA\resources\views\petani\index.blade.php)。我该如何解决?
控制器:
public function index(){
$post = Desa::all();
return view('petani.index',compact ('desas'));
}
路线:
Route::get('petani', 'BiodataController@index');
指数:
<?php
$no = 1;
?>
@foreach ($posts as $post)
<td>{{$no++}}</td>
<td>{{$post->nama}}</td>
<td>
<button type="button" class="btn"><a href="{{ URL::to('coba/test/'.$post->id.'/edit') }}" >Edit</a></button>
{{ Form::open(['url' => 'coba/test/'.$post->id, 'method' => 'DELETE']) }}
{{ Form::button('delete', ['type' => 'submit', 'class' => 'btn']) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
而不是 compact('desas')
,输入 ['posts' => $post]
就可以了