我有这个:
#include <boost/signals2.hpp>
#include <iostream>
#include <memory>
struct MySlot
{
void operator()(std::unique_ptr<int>&& input) const
{
std::cout << "Signaled " << *input.get();
}
};
int main(int argc, char* argv[])
{
boost::signals2::signal<void(std::unique_ptr<int>)> signal;
signal.connect(MySlot());
auto ptr = std::make_unique<int>(20);
signal(std::move(ptr));
}
但我想要的是这样的:
$comments = ArticleComments::orderBy('created_at','desc')->with('user')->with('article')->with('article.translations')->paginate(10);
我如何获得 $comments = ArticleComments::orderBy('created_at','desc')->with('user')->with('article')->with('article.translations')->whereHas('article.translations',function($query) use($default_language_id){
$query->where('language_id','=', $default_language_id )->first();
})->paginate(10);
但仅限于默认语言?现在我得到所有语言的所有翻译
答案 0 :(得分:1)
您不需要在此处使用translations
。使用eager load contraining功能。此代码仅为默认语言加载ArticleComments::orderBy('created_at','desc')
->with(['user', 'article', 'article.translations' => function($q) use(default_language_id) {
$q->where('language_id', $default_language_id);
}])->paginate(10);
:
angular.module('SCtrl', ['ng-fusioncharts']).controller('SCtrl', function($scope, $http) {
//Get All errors.
$http({
method: 'GET',
url: 'node/errors'
}).then(function successCallback(response) {
$scope.notifications = response.data;
console.log($scope.notifications);
}, function errorCallback(response) {
});
}