Skip to content

Authorization in nested resource #52672

Closed Answered by Barbapapazes
Barbapapazes asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I found a solution.

I rename TalkQuestionPolicy to QuestionPolicy to match the model name. Then, I pass the question class as first argument and then the talk.

    public function create(Talk $talk)
    {
        Gate::authorize('create', [Question::class, $talk]);

        return Inertia::render('Questions/Create');
    }

I think, the documentation could contains more example of nested resource!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Barbapapazes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant