Php 模型绑定没有';拉威尔5号
我现在正在使用模型绑定。但我抓不到通配符字符串 这是route.phpPhp 模型绑定没有';拉威尔5号,php,laravel-5,Php,Laravel 5,我现在正在使用模型绑定。但我抓不到通配符字符串 这是route.php Route::bind('video', function($video) { return App\Video::where('videoID', $video)->first(); }); Route::get('/result/{video}', 'IndexController@show'); 这是我的控制器方法 public function show(Video $video) { $v
Route::bind('video', function($video) {
return App\Video::where('videoID', $video)->first();
});
Route::get('/result/{video}', 'IndexController@show');
这是我的控制器方法
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'));
}
当我在控制器中使用dd($video)
时。我没有捕捉到任何数据
我已经检查过我的数据库了。它很好用
我错过了什么吗?尝试更改为:
public function show($video) {
您的路由可能已缓存。试一试
php artisan route:clear
再次缓存它们
php artisan route:cache
你能给我们看看你的控制器吗?你的路线被缓存了吗?试试php artisan route:clear@andrewtweber你是对的。我忘了做这个。但我不能选择您作为答案。使用此选项我可以捕获字符串,但模型绑定不起作用。