Put from session $s, from auth $a, and just compare the two. Oh the one from database is bcrypted. Why are you doing this? And how are you storing the session?
Aug 13, 2017
10
Level 2
Get UserID from database and compare with logged-in user
Hi,
i want to compare two userid's (fetched from the session and database)
Table "host":
id
name
user_id
....
Table "users":
id
name
....
Now in my controller i want to execute a simple SELECT-Query like:
$host = DB::table('hosts')->select('user_id')->where('id', $id)->get();
and compare the returned user_id with the current logged in user
$id = Auth::id();
Simple if-statement should do the trick, but it does not work. Any idea? :)
Level 122
public function show($id)
{
$host = Host::where('user_id',Auth::id())->where('id',$id)->first();
if($host){
return $host;
}
return redirect()->action('HostsController@index');
}
Please or to participate in this conversation.