New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
leftJoinSub() is not a method in Laravel<5.6 #171
leftJoinSub() is not a method in Laravel<5.6 #171
Comments
I'm also facing the same issue on Laravel I've downgraded to version |
@nticaric Laravel 5.5 face the same problem
|
We will take care of this. |
Can anyone test this fix: replace
|
Fix didn't work. Will work on it later this week. |
Running into this as well when using |
I am also running into this problem. any news of a fix soon? |
How about this: Replace the with
And on top add: |
Getting the same error in a Laravel 5.5 app. I was able to fix by adding the missing methods as macros in my use Closure;
use InvalidArgumentException;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
// needed because of the TNT search scout package uses methods that are specific from laravel 5.6
// may be able to remove this if this app gets upgraded OR they fix the issue: https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/171
QueryBuilder::macro('joinSub', function ($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false) {
list($query, $bindings) = $this->createSub($query);
$expression = '('.$query.') as '.$this->grammar->wrap($as);
$this->addBinding($bindings, 'join');
return $this->join(new Expression($expression), $first, $operator, $second, $type, $where);
});
QueryBuilder::macro('leftJoinSub', function ($query, $as, $first, $operator = null, $second = null) {
return $this->joinSub($query, $as, $first, $operator, $second, 'left');
});
QueryBuilder::macro('createSub', function ($query) {
if ($query instanceof Closure) {
$callback = $query;
$callback($query = $this->forSubQuery());
}
return $this->parseSub($query);
});
QueryBuilder::macro('parseSub', function ($query) {
if ($query instanceof self || $query instanceof EloquentBuilder) {
return [$query->toSql(), $query->getBindings()];
} elseif (is_string($query)) {
return [$query, []];
} else {
throw new InvalidArgumentException;
}
}); |
@nticaric how to solve this issue? |
got this : BadMethodCallException when i user method $posts = Post::search($request->get('query'))->where('status' , 1)->orderBy('published_at', 'DESC')->paginate(4); but working smoothly when just use $posts = Post::search($request->get('query'))->get(); i dunno why, help me. thank you |
See #189 for a possible fix. |
Trying to apply pagination on a query with where clauses results in an error for L5.5 or older.
leftJoinSub()
is only a method in L5.6.Call to undefined method Illuminate\Database\Query\Builder::leftJoinSub()
The text was updated successfully, but these errors were encountered: