laravel accessor appends not working as expected / strange behavior

Posted 3 months ago by jaheller

I'm using an accessor on my user model:


protected $appends = ['is_vendor'];

public function vendorDetails()
    return $this->hasOne('App\VendorUser');

//returns the vendor status of a user
public function getIsVendorAttribute()
    return (is_null($this->vendorDetails)) ? false : true;

public function currentLevel(){

        return $this->hasOne('App\VendorLevel', 'id', 'current_level');
        return $this->hasOne('App\UserLevel', 'id', 'current_level');



inside my controller returns a UserLevel for the current user, but when I call


it's returning true. Any idea where things go wrong? When I dump the whole user object:


I can see the append attribute only in the appendssection:

#appends: array:1 [▼
  0 => "is_vendor"

It's not listed under the #attributes property of the model.

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

Reply to

Use Markdown with GitHub-flavored code blocks.