我正在创建一个新应用程序我有一个全新安装的Laravel 5.1,我安装了来自Themeforest的JOSH主题,然后安装了你的mongodb软件包和你创建的哨兵包。
现在只有一个名为User的模型,它就在其中:
<?php namespace App;
use Jenssegers\Mongodb\Model as Eloquent;
class User extends Eloquent {
protected $connection = 'mongodb';
/**
* The database table used by the model.
*
* @var string
*/
// protected $table = 'users';
protected $collection = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
/**
* To allow soft deletes
*/
use SoftDeletes;
protected $dates = ['deleted_at'];
}
当我去我的开发网址时,这就是我得到的。
ErrorException in Builder.php line 211:
Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given, called in /var/www/actioncoach.com/subdomains/leads/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 1899 and defined
in Builder.php line 211
at HandleExceptions->handleError('4096', 'Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given, called in /var/www/actioncoach.com/subdomains/leads/vendor/laravel/framework/src/Illuminate/Database/Eloqu ent/Model.php on line 1899 and defined', '/var/www/actioncoach.com/subdomains/leads/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php', '211', array('connection' => object(Connection))) in Builder.php line 211
at Builder->__construct(object(Connection), null, object(Processor)) in Model.php line 1899
at Model->newBaseQueryBuilder() in Model.php line 1838
at Model->newQueryWithoutScopes() in Model.php line 1812
at Model->newQuery() in Provider.php line 75
at Provider->findById('2') in Sentry.php line 266
at Sentry->check() in Facade.php line 207
at Facade::__callStatic('check', array()) in AuthController.php line 25
at Sentry::check() in AuthController.php line 25
at AuthController->getSignin()
at call_user_func_array(array(object(AuthController), 'getSignin'), array()) in Controller.php line 256
at Controller->callAction('getSignin', array()) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(AuthController), object(Route), 'getSignin') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(AuthController), object(Route), object(Request), 'getSignin') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AuthController', 'getSignin') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
这是我的composer.json
的一部分{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"illuminate/html": "~5.0",
"jenssegers/mongodb": "^2.1",
"jenssegers/mongodb-sentry": "^1.0",
"cartalyst/sentry": "dev-feature/laravel-5"
},
这是我建议编辑的数据库文件:
// 'default' => env('DB_CONNECTION', 'mongodb'),
'default' => 'mongodb',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path('database.sqlite'),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
'mongodb' => array(
'driver' => 'mongodb',
'host' => 'mydburl',
'database' => 'actionleads',
'username' => 'action',
'password' => 'mysupersecretpassword',
'port' => 31223,
'options' => array(
'db' => 'actionleads' // sets the authentication database required by mongo 3
)
),
],
我试图在问题和疑难解答区域(https://github.com/jenssegers/laravel-mongodb)中找到我能找到的所有建议,到目前为止,我没有运气。你的帮助会很棒。
答案 0 :(得分:1)
对于遇到此问题的其他人,请进入您的Config文件夹并编辑文件&#34; cartalyst.sentry.php&#34;。
更改Sentry配置模型部分:
'groups' => array(
'model' => 'Jenssegers\Mongodb\Sentry\Group',
),
'users' => array(
'model' => 'Jenssegers\Mongodb\Sentry\User',
),
'throttling' => array(
'model' => 'Jenssegers\Mongodb\Sentry\Throttle',
),
答案 1 :(得分:0)
您需要更改文件:照亮/基金会/ Auth / User.php
要:
<?php
namespace Illuminate\Foundation\Auth;
use Illuminate\Auth\Authenticatable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Eloquent implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
}
它对我有用。