samedi 2 février 2019

Which is better way to verify access method In Laravel

I've Blog website where all user can post Blog.I have learned about Gates,Policy and Middleware .Please come to know that i am using Auth() Default Authentication Process in Laravel. I want to protect user (A) blog from other users.

Now I have many things to handle this.

Using Auth if(Auth()->user->id==$blog->user_id)

Using Gate if(Gate::Allow('blog_protection',$blog))

Using Policy if(Auth::user()->cant('blog_protection',$post))

Using Middleware $this->middleware('blog_access')

Please tell if i am wrong Meaning of that functions then what is best method to handle this request for more reusable . Many Thanks In Advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire