V
V
Vladislav2017-03-10 15:07:08
Laravel
Vladislav, 2017-03-10 15:07:08

How to give access only to the user with his id and his data?

How on the page to make access only one user with his id and with his data?
Post::find(Auth::user()->id)
How to translate this to Sentinel
I don't understand a little here is the controller
public function store(Request $request){
$hom = new House;
$hom->description = $request->description;
$hom->country = $request->country;
$hom->region = $request->region;
$hom->street = $request->street;
$hom->nomer_doma = $request->nomer_doma;
$hom->user_id = Sentinel::getUser()->id;
$hom->save();
return redirect('/house');
}
public function index(){
$homs = House::all();
return view('house.index', compact('homs'));
}
public function create(){
return view('house.create');
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mokhirjon Naimov, 2017-03-13
@lavreno63

$homs = House::where('user_id', Sentinel::getUser()->id)->get();

if (Sentinel::check()) {
    $homs = House::where('user_id', Sentinel::getUser()->id)->get();
} else {
    $homs = House::get();
}

A
Andrew Ghostuhin, 2017-12-13
@Torin_Asakura

Well, just like ReactJS, only, here's the question - were you going to write for iOS?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question