Support the ongoing development of Laravel.io →
Authentication

If you have watched the Laracast titled "Ogres Are Like Middleware" then I've based this question off of that.

From Jeffrey's example, basically, I am wondering how do you use a filter to restrict one user from editing another user's article?

I had such a function built into my Laravel 4.2 filter, but now the following code doesn't work because the middleware file I created "RedirectIfWrongUser" won't recognize the $article = Articles::find($id) code statement I had previously used. The reason why it won't work is because the Articles:: class is apparently not being recognized from within the Middleware file I made ("RedirectIfWrongUser").

Any constructive guidance would be most appreciated.

You can answer this question on StackOverflow if you like, where I have include some code blocks: http://stackoverflow.com/questions/31867873/creating-a-laravel-5-1-middleware-that-can-access-my-model

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.