In my app there is a model called Role which extends Model, all existing roles extend that class. All of these roles have to be found via one method or function. However there's no documentation for Reflection in laravel, although it's unwanted to create another implementation of reflection in php. Laravel'ish solution is preferred, because replicating existing solution is meaningless
Asked
Active
Viewed 310 times
0
-
you dont have all the roles in an array or container object? its impossible to answer the question without seeing the full class structure. – DevDonkey Feb 18 '19 at 11:20
-
Possible duplicate of [Get all defined classes of a parent class in php](https://stackoverflow.com/questions/6671398/get-all-defined-classes-of-a-parent-class-in-php) – Mihai Matei Feb 18 '19 at 11:21
-
No, role is represented as eloquent model due to huge structure diffrence. For instance: teacher and student – Artshellorok Feb 18 '19 at 11:24
-
@Artshellorok what do you actually look for is called relationships https://laravel.com/docs/5.7/eloquent-relationships – Mihai Matei Feb 18 '19 at 11:28
-
In my app i have User model which has relations with roles: other models which extend Role (blueprint model), all such models(which extend Role) have to be found(doesn't matter which way, btw i tried getting all relationships as array(it's impossible)). – Artshellorok Feb 18 '19 at 11:36
-
@Artshellorok Does the child classes like `Student` class have its own separate table or its still reflecting roles table? – Mihir Bhende Feb 18 '19 at 13:22
-
Separate of course – Artshellorok Feb 19 '19 at 09:35