In my Laravel controller I use the following code:
$usernotes = DB::select('SELECT note_id FROM note_user WHERE user_id = 1');
This is supposed to fetch the note_id from my many-to-many table, and it does. But return $usernotes; outputs
[{"paper_id":15}]
This looks like an array or a string, but I just need a plain integer 15 so I can put it into something like
$somevariable = someModel::find($usernotes)
$usernotes doesn't look like a number and running the above line gives me an error:
ErrorException in helpers.php line 740: Object of class stdClass could not be converted to string
How can I return just that number 15 out of that string?