You can break off from a query and continue it as you please.
$funs_query = DB::table('funs')
->select(array('funs.*', 'user_votes.like_vote', 'user_votes.dislike_vote', 'user_votes.user_id'))
->leftjoin('user_votes', 'user_votes.fun_id', '=', 'funs.id')
->where('funs.visible', '=', '1');
if (Auth::check()) {
$funs_query->where('user_votes.user_id', '=', Auth::user()->id);
}
$funs_result = $funs_query->orderBy('funs.created_at', 'desc')
->groupby('funs.id')
->take(3)->get();
Thanks for reply:) i solved my problem with this query
$funs_query = DB::table('funs')
->select(array('funs.*', 'user_votes.like_vote', 'user_votes.dislike_vote', 'user_votes.user_id'))
->leftjoin('user_votes', function($join){
$join->on('user_votes.fun_id', '=', 'funs.id')
->where('user_votes.user_id', '=', Auth::user()->id);
})
->where('funs.visible', '=', '1')
->orderBy('funs.created_at', 'desc')
->groupby('funs.id')
->take(3)->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community