What should I put as the return value for the docblock in the Laravel 4 eloquent model class

StackOverflow https://stackoverflow.com/questions/17978174

  •  04-06-2022
  •  | 
  •  

Question

I have the following basic class setup:

class Document extends Eloquent {

    /**
     * [types description]
     * @return [type] [description]
     */
    public function types() {
        return $this->belongsToMany('Type');
    }

}

What value would be appropriate to put in the return type doc block? Doing a var dump of the return method points the object \Illuminate\Database\Eloquent\Relations\BelongsToMany

Would that be correct in this instance? (I'm not really sure why if so?)

Thanks

Was it helpful?

Solution

The same Laravel is using:

@return \Illuminate\Database\Eloquent\Relations\BelongsToMany

Take a look at the file

vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php

OTHER TIPS

It returns an array at the most basic level....though I would just call it a Relationship....as thats kinda self explanatory, and thats what Laravel calls it in its docblock

class Document extends Eloquent {

/**
 * [types description]
 * @return Relationship 
 */
public function types() {
    return $this->belongsToMany('Type');
}

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top