Restricting access to authenticated user data - Laravel 5.3

1

I have a table that relates to another and that relates to some user. How do I make it so that only the owner of this relationship can change / delete the item. Even if I just bring in the form the records that are related, if by chance I change the identifier that I am passing I can change then I would like to know if there is any way to perform this verification internally in some generic way because I have several cases like this .

    
asked by anonymous 11.11.2016 / 20:30

1 answer

2

You can access the authenticated user on the server side.

Auth::user()->oAtributoQueDeseja

or assign it to a temporary user:

$user = Auth::user();

Remembering that you need to import this Facade

use Illuminate\Support\Facades\Auth;
    
11.11.2016 / 20:35