I'm working on Laravel and got stuck in this mess of undefined variable $category, I don't know why and where is the exact problem.
I have done this much.
AdminAjaxController
public function category()
{
$category=DB::select('select category_name,category_id from categories');
return view('admin.category_table',compact('category'));
}
category_table View
<table id="category" class="table">
<thead>
<tr>
<th>ID</th>
<th>Category Name</th>
<th>Delete</th>
<th>Update</th>
</tr>
</thead>
<tbody>
@foreach($category as $value)
<tr>
<td>{{ $value->category_id}}</td>
<td>{{ $value->category_name}}</td>
<th>Delete</td>
<td>Update</td>
</tr>
@endforeach
</tbody>
</table>