dimanche 3 septembre 2017

Laravel Spark Protect Restful Nested Resources

How do i protect nested resources? I have an app i am building. User owns Projects Projects have Tasks Tasks created by any user given permission.

Basically if you own the project you can see all tasks, but you cant see tasks outside of your own project (unless you were assigned them)

//Return list of Users Projects
User::find(Auth::id())->projects();

//Return List of ALL Users Tasks
User::find(Auth::id())->tasks();

How do i return all tasks for a project owned by a user? (Task may have been created by another user)

//Return All task for a project owned by user
User::find(Auth::id())->project($project_id)->tasks()->get();
Project::find($project_id)->where('owner', Auth::id())->tasks()->get()

Neither of those work. So what am i doing wrong? I am sure I am over looking something simple, but i have missed it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire