vendredi 16 octobre 2015

laravel 5 how to pass data to a name route from a view?

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>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1MuNGwI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire