Я не могу проверить, есть ли данные в переменной в laravel 6. Вот функция. Здесь проблема заключается в том, что $tags->count()
не выполняет команду else
public function index(){
$tags = Constant_model::getDataAllWithLimit('tags',"id",'DESC',50);
if ($tags->count() >0) {
$data = array(
'title'=>'All Tags',
'description'=>'All Tags',
'seo_keywords'=>'All Tags',
'tags'=>$tags
);
return view('tags',$data);
}else{
$data = array(
'title'=>"Page Not found",
'description'=>"Page not found",
'seo_keywords'=>'',
);
return view('404',$data);
}
}
. Вот функция getDataAllWithLimit
public static function getDataAllWithLimit($table,$order_column,$order_type,$limit){
$data = DB::table("$table")->orderBy("$order_column", "$order_type")
->paginate($limit);
return $data;
}
.