Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation from model call by not view in Laravel 4

Viewed 9115

I have a model, Ability, which belongs to another model AbilityType.

    <?php
class Ability extends Eloquent {

    public function abilityType() {
        return $this->belongsTo('AbilityType');
    }

    public function name() {
        return $this->abilityType->name;
    }
}

I can make this call in my blade template successfully:

$ability->abilityType->name

But when I make that same call in my Ability model, it throws an exception:

ErrorException Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

Do the dynamic properties differ in behavior between view and model layer? What am I missing here?

1 Answers
Related