jeudi 19 mai 2016

Check laravel Eloquent Model attribute behavior

Recently I did an update from Laravel 5.0 to 5.1 and PHP from 5.6 to 7.0.

I see some unknown for me behavior.

$user = User:find(1);

if(!empty( $user->email )){

    //some fancy function
}

The code above doesn't work. When I dd(!empty( $user->email )) It says false But when I add one logging functionality it works and dd(!empty( $user->email )) returns true

$user = User:find(1);

Log::info($user->email);

if(!empty( $user->email )){

    //some fancy function
}

I'm not so familiar with laravel and I understand that eloquent is doing some magic show behind the scenes. So my question is what and why?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire