L
L
lynnikvadim2015-12-06 15:19:13
Laravel
lynnikvadim, 2015-12-06 15:19:13

Give data from the database only to the one who created it?

How or with the help of what is it better to make the data so that only the user who added it to the database can edit the data?
Can this somehow be organized using Laravel ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav, 2015-12-06
@mzcoding

Well the simplest

if(Auth::user()->id === $db->user_id){
  //создал, может редактировать
}else{
  // не может редактировать
}

And so read laravel.com/docs/5.1/authorization

R
romy4, 2015-12-06
@romy4

Store user_id in the table and check before editing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question