Laravel ORM调用范围函数关系

I am trying to load a relationship from my customer table into my orders table but every time I try I keep getting this error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to a member function where() on a non-object

Here is my model for the orders

class Orders extends Eloquent
{
    protected $softDelete = true;

    public function order_items()
    {
        return $this->hasMany('Order_item');
    }

    public function customer()
    {
        return $this->hasOne('Customer', 'id', 'customer_id');
    }

    public function client()
    {
        return $this->hasOne('Client', 'id', 'client_id');
    }

    public function billingAddress()
    {
        if($this->client()->first() != null)
        {
            return $this->client()->getBillingAddress($this->billing_address_id);
        }
        else
        {
            return $this->customer()->getBillingAddress($this->billing_address_id);
        }
    }
}

Here is my customer model

class Customer extends Eloquent
{
    protected $softDelete = true;

    public function order()
    {
        $this->belongsTo('Orders');
    }

    public function addresses()
    {
        $this->hasMany('Customeraddress', 'id', 'customer_id');
    }

    public function scopeGetBillingAddress($query, $addressId)
    {
        return $this->addresses()
                    ->where('id', '=', $addressId)
                    ->where('type', '=', 'billing');
    }

    public function scopeGetShippingAddress($query, $addressId)
    {
        return $this->addresses()
                    ->where('id', '=', $addressId)
                    ->where('type', '=', 'shipping');
    }
}

And finally here is my customeraddress model:

class Customeraddress extends Eloquent
{
    protected $table = "customer_addresses";
    protected $softDelete = true;

    public function customer()
    {
        $this->belongsTo('Customer');
    }
}

Now I am trying to run this on my controller to get the order address but I keep getting errors. How would I be able to do that via Eloquent relationship and scope function?

$address = Orders::find(21)->billingAddress()->first();
echo $address->street;

Change this one:

public function addresses()
{
    // $this->hasMany('Customeraddress', 'id', 'customer_id'); // wrong order of keys
    return $this->hasMany('Customeraddress', 'customer_id', 'id');
}

and these two

// edit: Order is a child of customer and client so:
public function customer()
{
    //return $this->hasOne('Customer', 'customer_id', 'id');
    return $this->belongsTo('Customer', 'customer_id', 'id'); // customer_id and id are redundant bu I leave it for clarity
}

public function client()
{
    //return $this->hasOne('Client', 'client_id', 'id');
    return $this->belongsTo('Client', 'client_id', 'id'); // same here
}

And by the way, this one is dangerous :)

public function billingAddress()
{
    // This line results in db query everytime you call billingAddress 
    // Unless you cache the query, it's overkill
    if($this->client()->first() != null)

    // instead use:
    if($this->client != null)

    {
        return $this->client()->getBillingAddress($this->billing_address_id);
    }
    else
    {
        return $this->customer()->getBillingAddress($this->billing_address_id);
    }
}

change scopes to accessors:

public function getBillingAddressAttribute($addressId)
{
    return $this->addresses()
                ->where('id', '=', $addressId)
                ->where('type', '=', 'billing')->first();
}

public function getShippingAddressAttribute($addressId)
{
    return $this->addresses()
                ->where('id', '=', $addressId)
                ->where('type', '=', 'shipping')->first();
}

// then you can call it like $customer->shippingAddress etc