0

generally my aim is to pass a data that will serve as identifier in an href attribute..

my route is somethign like this.

Route::bind('video', function($slug){
return DB::table('videos')
            ->select('slug')
            ->where('slug', $slug)
            ->first();
});

$router->get('/vid/{video}', ['as' => 'video_page', 'uses' => 'HomeController@vid']);

my controllers method is this.

 public function vid($video){
    $slug = $video->slug;

    return $slug;
 }

and in my view.

 <a href="{{ route('video_page') }}">{{ $vid->title }}</a>

my question is how to pass data that would look like this,

 <a href="/vid/my-slug">my-title</a>
Glad To Help
  • 5,299
  • 4
  • 38
  • 56
johnguild
  • 435
  • 1
  • 5
  • 25

1 Answers1

1

Pass a second parameter to the route() function. Like this:

<a href="{{ route('video_page', ['slug' => $vid->slug]) }}">{{ $vid->title }}</a>
Glad To Help
  • 5,299
  • 4
  • 38
  • 56