DB::collection('test_collection')->all(); works fine, but when i use my _TestCollection_ model i get _PHP Fatal error: Call to a member function all() on array in \vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php on line 609_.
TestCollection model:
namespace App\Models;
use Moloquent;
class TestCollection extends Moloquent{
protected $connection = 'mongodb';
protected $collection = 'test_collection ';
protected static $unguarded = true;
}
TestCollection controller:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Models\TestCollection;
class MongoController extends Controller{
public function index(Request $request){
return TestCollection::all();
}
}
Are you sure you are extending the correct Model ?
Try this in your TestCollection model
use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
Any update on this? Relations not working for me. Laravel 5.3
FatalErrorException in Builder.php line 613:
Call to a member function all() on array
MySql relations are working fine.
Same error
Call to a member function all() on array
Insight -
App\Video::take(10)
=> Jenssegers\Mongodb\Eloquent\Builder {#714}
DB::collection('video')->take(10)
=> Jenssegers\Mongodb\Query\Builder {#709
Notice both are returning different objects.
@nitinsurana please update you composer dependency version to 3.1.0-alpha and do run composer update
I can confirm that the error is not there in version 3.1.0-alpha. You may close this issue.
@pi0 works, thanks.
I am still getting the same error in 3.1.0-alpha.
@alexjose it will certainly work, but if you still have problems you could also try Moloquent :)
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function compileSelect() on null
same issue getting in 3.2 also
call any api its throw an error
FatalErrorException in Builder.php line 1581:
Call to a member function compileSelect() on null
After composer update getting same error with mongodb
Most helpful comment
@nitinsurana please update you composer dependency version to
3.1.0-alphaand do runcomposer update