This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I want to create a app that will be basic only the back-end (80% CRUDs) no front-end.
- But I will have users and this users can create "child" users and so on.
- In the listings, I want to list items of the logged user and his childs. How can I do that with OCMS?
Thanks.
I want to do the same thing on my project but have no idea how to do that. Did you have success? Thanks :)
Hi @justin.vietz16243, I have thought a lot about this, but haven't found a bullet proof/state of the art solution.
If your tree is simple, you can add a parent_id
at backend_users
then use beforeSave
hook to insert the current logged user ID. Also, add something like owner_id
or just user_id
to models that needs to have ownership, then filter at listExtendQueryBefore
.
If its more complex, you maybe should try something with October's implementation of nested tree, but I'm not sure you can extend Backend\User
on that level.
@daftspunk to rescue!
Duno how to mention :/
Last updated
Thanks for your reply. Currently I have a Model named Profile where I store a profile ID. So every time a Adminuser creates a childuser the child user will have the same profile ID as the Admin user. I've connected the backend User Model to my profile with "$belongsTo". Right know i have no idea how to query that "Profile-Table" in my Plugins boot section via "listExtendQuery".
I would be very grateful if you would help me :) If you need further information just write me.
Not sure if I understood your problem, but maybe you can use whereHas
Profile::whereHas('user', function ($query) {
$query->where('id', Auth::user()->id);
})->get();
Something like that.
1-6 of 6