im working on laravel project and now its giving me this error:Use of undefined constant category – assumed ‘category’ (this will throw an Error in a future version of PHP)
and its pointing at lane 26
even though i declared the variable ‘category’ any ideas how to solve it ? thank you
@extends('layouts.app')
@section('content')
<div class="card">
<div class="card-body">
<table class="table table-hover">
<thead>
<th>
Category Name
</th>
<th>
Editing
</th>
<th>
Deleting
</th>
</thead>
<tbody>
@foreach($categories as $category)
<tr>
<td>{{$category->name}}</td>
<td>
<a href="{{ route(category.edit, ['id=>$category->id']) }}" class="btn btn-light btn-xs">
Edit
</a>
</td>
<td>
<a href="{{route(category.delete, ['id => $category->id'])}}" class="btn btn-danger btn-xs">
Delete
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop
2
Answers
Use this route variable in commas, It’s worked for me.
You need to change these below routes and i hope it will work for you!