Reputation: 1551
I'm trying to install Eloquence on my Laravel project.
I'm following the installation, and I've done the following:
Problem: Post::search('jarek sofa')->get();
results in
FatalThrowableError in Builder.php line 77:
Call to a member function make() on null
Possible reasons:
Thanks in advance
Upvotes: 0
Views: 2034
Reputation: 1
Sorry to bump an old topic, but I have a different solution to anyone who might find themselves here: you cannot have a scope called 'search'.
I just had the exact same exception and couldn't work out why, although I figured it was a problem with me trying to call a scope dynamically through call_user_func_array. Thanks to this question having the exact same scope name, I figured it might be that and it was. There's probably many other 'reserved' names I don't know about, but as soon as I changed it to 'searchName' all is well.
Upvotes: 0
Reputation: 966
I was having same issue resolved it as following added dependencies to the composer "require": { "sofa/eloquence": "~5.3", // for Laravel 5.3.*
// OR
"sofa/eloquence": "~5.2", // for Laravel 5.2.*
// OR
"sofa/eloquence": "~5.1", // for Laravel 5.1.*
// OR
"sofa/eloquence": "~0.4", // for Laravel 5.0.*
...
},
then added the class in config/app 'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
.....
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
Sofa\Eloquence\ServiceProvider::class,
],
finally did the composer update
Upvotes: 0
Reputation: 1551
Finally got it to work!
Solution: Add \Sofa\Eloquence\Builder::setParserFactory(new \Sofa\Eloquence\Searchable\ParserFactory);
in the AppServiceProvider
boot method like this:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\Sofa\Eloquence\Builder::setParserFactory(new \Sofa\Eloquence\Searchable\ParserFactory);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
Upvotes: 1