Seeding users return error
pwfraley opened this issue · 1 comments
pwfraley commented
When I am trying to seed my users collection/table I get the following error message:
[ErrorException]
Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given, called in /home/frpa/pmj/bootstrap/compiled.php on line 6965 and defined
Now I read in your mongodb driver about this error, but I did not define a custom user model.
My auth.php config for the models looks like this:
'model' => array(
'groups' => array(
'model' => 'Jenssegers\Mongodb\Sentry\Group',
),
'users' => array(
'model' => 'Jenssegers\Mongodb\Sentry\User',
),
'throttling' => array(
'model' => 'Jenssegers\Mongodb\Sentry\Throttle',
),
),
as driver setting in auth.php I tried: database, eloquent and moloquent (which I aliased in app.php) but all produce the same error. Since I did not define a User Model, there should not be the inheritance problem or do I have to define a custom user model in order for this to work?
My seed file looks like this:
<?php
class SentrySeeder extends Seeder {
public function run () {
echo "Seeding Users ...";
// Empty all user related tables
DB::table('users')->delete();
DB::table('groups')->delete();
DB::table('users_groups')->delete();
// Create a new user
Sentry::getUserProvider()->create(array(
'email' => 'patrick@dvinci.de',
'password' => "password",
'first_name' => 'Patrick',
'last_name' => 'Fraley',
'activated' => 1,
));
// Create an admin group
Sentry::getGroupProvider()->create(array(
'name' => 'Admin',
'permissions' => array('admin' => 1),
));
// Assign user permissions
$adminUser = Sentry::getUserProvider()->findByLogin('patrick.fraley@dvinci.de');
$adminGroup = Sentry::getGroupProvider()->findByName('Admin');
$adminUser->addGroup($adminGroup);
echo "Seeded.";
}
}
pwfraley commented
You can close this issue. I changed the model in auth.php and not in the sentinel config. After I changed it in there everything seems to work fine :)