Invalid argument supplied for foreach() in Laravel 5.5
I am trying to retrieve records from my database but I always end up getting an invalid argument error in the @foreach. My syntax looks correct and I cannot find where the problem is. Kindly help out.
role.blade.php
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<!-- <th></th> -->
<th>Name</th>
<th>Company ID</th>
<th>Role Type</th>
</tr>
</thead>
<tbody>
@foreach ($data as $datas)
<tr>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
controller.php
public function roles(){
$data = DB::select('select * from roles');
return view('admin.roles', ['data'=>'$data']);
}
routes.php
Route::get('/roles', 'mainController@roles');
from Laravel Questions and Answers https://laravelquestions.com/php/invalid-argument-supplied-for-foreach-in-laravel-5-5/
via Lzo Media
No comments:
Post a Comment