php - Laravel 5 polymorphic relationship with foreign key -
tables:
roles
-id -role users
-id -role_id schools
-id (primary, foreign-references id on users) -other attributes consultancies
-id (primary, foreign-references id on users) -other attributes students
-id (primary, foreign-references id on users) -other attributes school, consultancies , students specialization (or generalization?) of users.
in model class, trying establish polymorphic one-to-one relationship. seems straight forward if there had not been roles table , role_id in user table had been string: role.
but structure, how relationships work?
Comments
Post a Comment