-1

Right now I have authentication setup but when an authenticated user creates new data, any authenticated user can see that data and manipulate it. I would like to make it so that each user can only see the data they created. I am new to laravel and php so I don't really know how to set this up!

I can share any code or more details if needed, just let me know!

Thanks

L. Fox
  • 328
  • 1
  • 6
  • 20
  • 1
    Go for it. Let us know how it works out. – RiggsFolly Mar 22 '18 at 15:24
  • 3
    To ask an On Topic question, please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [What topics to avoid](https://stackoverflow.com/help/dont-ask) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) and [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) and how to create a [Minimal, Complete and Verifiable Example](http://stackoverflow.com/help/mcve) and [take the tour](http://stackoverflow.com/tour) **We are very willing to help you fix your code, but we dont write code for you** – RiggsFolly Mar 22 '18 at 15:25
  • use Gate https://laravel.com/docs/5.6/authorization – Indra Mar 22 '18 at 15:26

1 Answers1

0

One of the ways to do it is to create a user_id foreign key in your data table. Then filter data against logged in user id.

For example you have a products table. Create a user_id foreign key in products table. Then setup relationship between products and users. So when you show all products info, filter products that matches logged in user id.

Hope this will help you.

Ahsan
  • 1,289
  • 3
  • 13
  • 37