这是我的路线。
Route::get('discussion/{slug}',[
'use' => 'DiscussionsController@show',
'as' => 'discussion.show'
]);
这是显示功能
public function show($slug)
{
$discussion = Discussion::where('slug', $slug)->first();
return view('discussions.show', compact('discussion'));
}
我收到此错误。
这样查看文件
@section('content')
<div class="card">
<div class="card-header">{{$discussion->tittle}}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
</div>
</div>
@endsection
在这里我称重定向路由,并得到错误
$discussion = Discussion::create([
'tittle' => $request->title,
'content' => $request->contant,
'chanel_id' => $request->channel_id,
'user_id' => Auth::id(),
'slug' => str_slug($request->title)
]);
return redirect()->route('discussion', ['slug' => $discussion->slug]);
ERR_MSG :
答案 0 :(得分:0)
路线
Route::get('discussion/{slug}',['as'=>'discussion.show','use'=>'DiscussionsController@show']);
控制器
public function show($slug){
$discussion = Discussion::where('slug', $slug)->first();
return view('discuss', compact('discussion'));
}
您的刀片文件必须为describe.blade.php
您将使用该讨论。如果您仅在视图页面上需要这样的内容,请显示
<a href="{{route('discussion.show',['slug'=>$discuss->slug])}}">View Slug</a>