Reputation: 143
I am using model binding now. But I can't catch the wildcard string.
Here is the route.php
Route::bind('video', function($video) {
return App\Video::where('videoID', $video)->first();
});
Route::get('/result/{video}', 'IndexController@show');
Here is my controller method
public function show(Video $video) {
$video_tag = Video_tag::where( 'id', $video->id )->get(['id', 'tag', 'time']);
$count = array();
foreach ( $video_tag as $tag ) {
$num = Video_tag::where(['id' => $video->id, 'tag' => $tag->tag])->get()->count();
array_push($count, $num);
}
$forJs = array();
$hasAdded = false ;
$size = count($video_tag);
foreach ( $video_tag as $k=>$tag ) {
if ( !$hasAdded ) {
$add = array( $count[$k] => $tag );
$hasAdded = true;
}
array_push($forJs, $add);
if ( $size-1 > $k && strcmp($video_tag[$k]->tag, $video_tag[$k+1]->tag) != 0 )
$hasAdded = false;
}
return view('viewVideo', compact('video', 'video_tag', 'count', 'forJs'));
}
When I use dd($video)
in Controller. I didn't catch any data.
I already check my database. It works fine.
Did I miss something?
Upvotes: 2
Views: 62
Reputation: 25509
Your routes are probably cached. Try
php artisan route:clear
To cache them again
php artisan route:cache
Upvotes: 1