mix359

Experience

70

0 Best Reply Awards

  • Member Since 4 Days Ago
  • 0 Lessons Completed
  • 0 Favorites

20th March, 2017

mix359 left a reply on Roles & Permissions • 4 days ago

Uhm, I haven't used entrust, but it seam similar to another system I'm using. Suddenly many of this system doesn't have any caching ability (from what I know, laravel doesn't use the caching system too much... it simply offer the utility to use it, but it doesn't integrate it with something for example the query result caching... so the packet written for laravel rarely use the cache)

If you don't want to change your permission system, I suggest to try to overwrite the model it's using (in my system I can extend them and pass the new Model through the configuration of the system) Or maybe you can do the same thing with the event system. In this way you can intercept the data queried to those model and cache them. But you also have to delete those data when you change something (like a role or a user-role association).

Hope that can help ;)

Cheers Daniele

mix359 left a reply on Multi User Type Model And Auth • 4 days ago

Thanks for the various answer :) I'm still thinking which solution to use, but some other point of view is interesting ;)

I'm trying to find a way to compare the various solution... maybe I can try to calculate the type and number of query that Eloquent should be do in the various situation... (If it's not too hard/long to do xD) There are some way to predict the result of a test like that? (without creating all the 3 structure, populate with random data and see the query number/time?)

To answer to @Snapey, yes they are all user of my application, watching from the authentication/permission point of view. Looking from other point, it could be something totally different.

For example, if I need to select the users of a classroom, the teacher have particular relation: the teacher-subject-classroom relation. The student have a direct relation with the classroom. The parent should be related to their child and then their child to the classroom.

For the 3 different types of user I have 3 different way to relate to other model. And in many part of my application I need to see they as Teacher, or Student, not as User.

I don't have only simple attributes or profile data to attach to the user. I have relation (and function) and it's different from user type to user type. So I need to have a Model for every type of user, where I can create relation and function that it's unique to that type of user (and the relation can be reversed in other Model, calling for example only the students).

Thanks again Cheers Daniele

mix359 started a new conversation Multi User Type Model And Auth • 4 days ago

Hi to all,

I've a strange situation, that initially seam simply, but it's really complicated to approach. I've to create a system that it's used in a school, so that have 3 different types of users:

  • Student
  • Parent
  • Teacher/Personal

My initial idea was to use 3 different Models/tables, one for user type. In this way is more simple to write many of the relation and controller code. And for the moment this approach worked, because I was only having the teacher/personal to login into the system. But now I have to permit the login of the students and the parents, that should see different thing, etc

To do that I've see to way, but I don't know which is the best/clearest:

  • First way is to use a common Account model, where all the users is, and a flag on the table that represent the user type. Then I will have the other 3 Model (Teacher, Student, Parent) extend the Account model, pointing to the accounts table, and having something like that: public function newQuery() { return parent::newQuery()->where('type', Account::ACCOUNT_TYPE_TEACHER); }

So every generic query that I made on the model, is filtered as a teacher.

I've used a similar approach in the past, and have worked well, but the situations was simpler that this. In this way I've probably a better situation for the authentication and permission management, because I have the same basic Account for all the type of users, but this should probably create some more complex query. Also I have to do other table that contain the data that is not shared from the various types of users: for example, a student have some information about his curriculum. And the difficult part is that I need some intermediary join table to some other table, for example a student will have a classroomId, and I need to have an intermediate table with studentId - classroomId. Or even more complex, a parent have a relation with the student, that is also in the same table.

  • Second way, have the three different Model and table for every user type. The pro of this solution is that I can have the "extra" field (that are not shared from the various user types) directly on the table, so I will have simpler relations and join.

The cons is that I have to use a multi-auth system, and I have to keep track in all the code and all the other Model of the user type. For example, if I need to save on an entity the user that created it, I have to save the user type, and the id of that user in his table (that change from type to type) That make also more difficult to manage the authorization/permission in the code, because I have to check the user type to select the correct user model, and then I can use the user id. So I need to modify or use a different auth system.

Thanks to all that can help me make this decision I wish that this post is clear enough to understand what I'm trying to do :) Cheers Daniele

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.