3 months ago

How to know what is inside an eloquent object

Posted 3 months ago by mirsahib

In Laravel eloquent documentation there is an example of user class


namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
     * Get the phone record associated with the user.
    public function phone()
        return $this->hasOne('App\Phone');

and below it says Dynamic properties allow you to access relationship methods as if they were properties defined on the model.

$phone = User::find(1)->phone;

my question is how to know what is inside the $phone variable (i know its an object but i want to know what are the attribute it has)

and please don't suggest var_dump,dd or ddd it's not helpful

Please sign in or create an account to participate in this conversation.