-
Notifications
You must be signed in to change notification settings - Fork 17
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
Using different model besides "User" #8
Comments
Hi Erik-jan, First of all don't run (or rollback)
If you have still an error, feel free to reopen this issue. Cheers, |
Thanks for the info, i did as you told me but i already had some stuff done so i just restarted from scratch. I redid the migrations file to point to the "Person" table i have. I see 3 tables created now and after running the same query it does load in the information exactly the same as it did when it created the information in the "User" table. When i use above lines from my first post, i can see the roles being added, but it does not correctly add the person_role entry's. I did a dump of the data while i did the insert and i can see it does find the correct "id" of the person in the Person table. Yet what it creates in my database is:
I did a print_r($person); print_r($roleAdmin);
And in the admin:
So why does it not take the id of the person as person_id ? |
It's weird, your // Create a 'admin' role
$role1 = new Role;
$role1->name = "admin";
$role1->save();
// Attach the 'admin' role to a person
$person= Person::where('email', 'Piet.hijn@hijn.nl')->firstOrFail();
$person->roles()->attach($role1->id); |
Still keeps it at 0 when i try it like that. Any other debug things i can try? |
So it's not a bug related to this package... |
eloquent, mysql. Set the auth.php to use table = person and model Person. Perhaps the default models for Permissions / Roles are not enough since i use Person? |
Can you show me your |
You can create a secret gist, share me the URL, then remove it after I read it. |
--hide url-- ow or a secret gist could work too, i just removed all non essential stuff. |
You have a custom primary key |
To keep your custom primary key, you can try to do this in your Person model: class Person extends Eloquent implements UserInterface, RemindableInterface {
//...
public function roles()
{
return $this->belongsToMany('Role', 'person_role', 'person_id', 'role_id');
}
public function permissions()
{
return $this->hasMany('Permission', 'person_id');
}
//...
} |
You can ask for more help on http://laravel.io/forum because now your issue is related to Eloquent associations with a custom primary key. Have a good day, |
Above snippet didn't resolve the issue. When i removed my primary key it did work as expected so yes indeed this is then a laravel/eloquent issue. Thanks for your help, i'll see if i can work around not using that primary key since your authority package looks the nicest :) |
I have a "Person" model, instead of the default "User" model. My app config is change to the auth model in "Person"
I try to seed some data into in it like:
I get the following error message:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'toolbox.person_role' doesn't exist (SQL: insert into
person_role
(person_id
,role_id
) values (dj40kl, 4))It looks like it appends the "role" to the person_ name. When using the default "User" model i did not have this issue. Do i need to create those tables instead of the default ones?
The text was updated successfully, but these errors were encountered: