[英]Use of undefined constant category Laravel error
我正在處理 laravel 項目,現在它給了我這個錯誤:使用未定義的常量類別 - 假定為“類別”(這將在 PHP 的未來版本中引發錯誤)並且它指向第 26 通道,即使我聲明了變量“類別” ' 任何想法如何解決它? 謝謝你
@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
用逗號使用這個路由變量,它對我有用。
<a href="{{ route('category.edit', ['id=>$category->id']) }}" class="btn btn-light btn-xs">
Edit
</a>
您需要更改以下路線,我希望它對您有用!
<a href="{{ route('category.edit', $category->id) }}" class="btn btn-light
btn-xs">Edit</a>
<a href="{{'route(category.delete', $category->id)}}" class="btn btn-danger btn-xs"> Delete </a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.