Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

THIS ACTION IS NOT AUTHORIZED. at the time of upgrade Laravel

I’m learning Laravel, practicing doing a project where I load documents (a crud).

I got to the point of doing the process of updating a document. When I click on the button I get the message THIS ACTION IS NOT AUTHORIZED, but I don’t have any permissions policy activated or created. I don’t know what this is due to.

Routes

Route::get('/document/{document}/edit', [DocumentController::class, 'edit'])->name('document.edit');
Route::put('/document/{document}/edit', [DocumentController::class, 'update'])->name('document.update');

In the first route I show the form and in the second one I make the logic to update it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    public function edit(Document $document)
    {
        return view('document.form-document-edit', [
            'document' => $document,
            'users' => User::all()
        ]);
    }

    public function update(UpdateDocumentRequest $request, Document $document)
    {
        return "update method is called";

I put the return in the update method to know if it would show me this message but it never shows me the return. I really don’t know what to do anymore, because I’m not getting anywhere.

I would love a little help in understanding the reasoning behind this.

>Solution :

It’s probably because in your UpdateDocumentRequest you didn’t set authorize method to return true:

public function authorize(): bool {
    return true; // change this to true, by default it's false
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading