0

This is my route.

 Route::get('discussion/{slug}',[
    'use' => 'DiscussionsController@show',
    'as' => 'discussion.show'
]);

This is show function

public function show($slug)
{
    $discussion = Discussion::where('slug', $slug)->first();

    return view('discussions.show', compact('discussion'));
}

i am getting this error.

view file like this

@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

here i call redirect the route, and get the error

$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:

error

handlerFive
  • 870
  • 10
  • 23
S Sarker
  • 3
  • 5
  • 1
    there is nothing here trying to generate a link to that route ... there is a stack trace that tells you where the error comes from – lagbox Aug 28 '18 at 16:31
  • Maybe problem in here: you defined your route as discussion.show and calling it like discussion. Please provide us more information – Samir Mammadhasanov Aug 28 '18 at 17:12

1 Answers1

0

Route

Route::get('discussion/{slug}',['as'=>'discussion.show','use'=>'DiscussionsController@show']);

Controller

public function show($slug){

   $discussion = Discussion::where('slug', $slug)->first();

   return view('discuss', compact('discussion'));
}

Your blade file must be discuss.blade.php

You are going to use that discussion.show if you only need something like this on your view page <a href="{{route('discussion.show',['slug'=>$discuss->slug])}}">View Slug</a>

Christian Gallarmin
  • 660
  • 4
  • 15
  • 34