php - How to get /user/8/lesson/79 to work without giving user access to all lessons? -
My two models are: a user model and a lesson model. The user for text is one of the many relationships. I have defined that it has many links in the user and text model.
Essentially, I want to force the user into my lessons; User 8 should not be able to access the Lessons of User 7
However, it does not work:
return user :: Search ($ userId) - & gt; Lesson () - & gt; Where ('id', $ id); and I do not want to say
return text :: search ($ lessonId) because it means That any user can do anything else with the lesson of another user.
I think what you want Route: Filters ('user-free'), function ($ route, $ request) {// is probably a better way of getting value from the request, // but I could not find it // $ uid = $ request- & gt; Segment (2); $ Lid = $ request- & gt; Segment (4); // Check user id and text value - Not sure how you want to test it; // I have just made up some // if (user: search ($ uid) -> gtc: gtc-> gt; lessons- & gt; contains ($ lid) (new unauthorized exception) ("You can not do this ! ");}); Root :: Receive ("user / {uid} / lesson / {}", array ("first" => "user-free"), function ($ uid, $ lid) {return " Can access! ";}));
Comments
Post a Comment