In a picture below we can see relations between my tables. My target is to get "type" from driver_license_types. Starting at user object. For example:
$user = User::find(1);
and from there I need to get type from driver_license_types. Important thing is that instructors can have few records in instructor_license_types table, like this:

My current solutions:
- In User model I create method instructor which is relation "belongTo" instructor model.
- in Instructor model I created method license which is relation "hasMany" with Instructor_license_types
- In Instructor_license_types, I create method types which is relation "hasMany" with Driver_license_types.
Is there any better solutions?
via Chebli Mohamed

Aucun commentaire:
Enregistrer un commentaire