-
Notifications
You must be signed in to change notification settings - Fork 602
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
Error when running artisan db:seed #168
Comments
Are you still getting this error? |
I am having this error running the said command. [BadMethodCallException] |
Didn't mean to close it :-) I have tried once again with no problems. So don't know what caused the problem. |
Hey guys, I too am getting this error like @carnevalle said. I am not sure why is it coming up. Any solution for this?
|
Fresh install |
This is not the exactly the same problem. But it is a very close error to open a new issues. Take a look: $ php artisan db:seed
PHP Fatal error: Trait 'Zizaco\Entrust\HasRole' not found in /vagrant/laravel/app/models/User.php on line 7
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Trait 'Zizaco\\Entrust\\HasRole' not found","file":"\/vagrant\/laravel\/app\/models\/User.php","line":7}}{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Trait 'Zizaco\\Entrust\\HasRole' not found","file":"\/vagrant\/laravel\/app\/models\/User.php","line":7}} $ cat composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"zizaco/confide": "dev-master",
"intervention/image": "dev-master",
"google/apiclient": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
} $ cat ./app/models/User.php
<?php
use Zizaco\Confide\ConfideUser;
use Zizaco\Entrust\HasRole;
class User extends ConfideUser {
use HasRole;
public $errors;
protected $table = 'user';
protected $softDelete = true;
protected $fillable = array('access_token', 'refresh_token');
public $skipValidations = false;
/**
* Validation rules
*/
public static $rules = array(
'email' => 'unique:users|required|email',
'password' => 'required|between:4,11|confirmed',
);
public static function boot() {
parent::boot();
static::saving(function($model) {
return $model->validate();
});
}
public function delete() {
$this->roles()->detach();
return parent::delete();
}
public function name() {
$arr = explode( '@', $this->email );
return array_shift( $arr );
}
public function setAccessToken($token) {
$this->skipValidations = true;
return $this->update(array(
'access_token' => $token,
));
}
public function validate(array $rules = array(), array $customMessages = array()) {
if ($this->skipValidations) return true;
$validator = Validator::make($this->attributes, static::$rules);
if ($validator->passes()) return true;
$this->errors = $validator->messages();
return false;
}
} |
me too with this same issue |
Call to undefined method stdClass::attachRole() I'm not completely new to Laravel (v4.2.*) and definitely not to PHP (PHP v5.4.19), so I understand what's going on here, but I can't get this to work:
models/user.php
|
You probably have a role relation in your User model that overrides the HasRole's role relation method. Remove it and it will work. |
I have the same Error PHP Fatal error: Call to a member function attachRole() on null in /var/www/b4x/app/database/seeds/RolesTableSeeder.php on line 18 I haven't an override for HasRole method |
if u combine confide with zicaco see your user model <?php
use Zizaco\Confide\ConfideUser;
use Zizaco\Confide\ConfideUserInterface;
use Zizaco\Entrust\HasRole;
class User extends Eloquent implements ConfideUserInterface
{
use ConfideUser;
use HasRole;
} |
When I run php artisan db:seed i get the following error message:
{"error":{"type":"ErrorException","message":"call_user_func_array() expects parameter 1 to be a valid callback, non-static method Role::beforeSave() should not be called statically","file":"/Users/me/Web/project/bootstrap/compiled.php","line":5233}}
I am completely new to Laravel, so don't know how and where to debug what is going on. Is it perhaps something with the validation of the model?
I can get it working if i substitute the content of RolesTableSeeder with
There is another problem, that you can't execute db:seed multiple times, as some ID's are hardcoded and running multiple db:seed will empty the table but not reset the incrementing ID's. To resolve this issue wipe the database and migrate before seeding.
The text was updated successfully, but these errors were encountered: