mardi 14 février 2017

retrieve single row in LARAVELusing eloquent

i am using laravel 5.1 and want to retrieve a single row in the database then manipulate it after.

my current code is

$profiles = Profile::where('user_id', $this->user->user_id)
->where('profile_code', $this->user->profile_code)
->get();

foreach($profiles as $profile ){
$data['address'] = $profile->address;
}

why cant i do it like this?

$profiles = Profile::where('user_id', $this->user->user_id)
->where('profile_code', $this->user->profile_code)
->get();

$data['address'] = $profiles->address;

am i using a wrong function or something? thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire