More than one relationship in the same model

0

My client class has a one-to-one relationship with endereco and one-to-many with contacts. How would the functions be in Cliente to work? and Migrate ?

    
asked by anonymous 30.09.2014 / 13:44

1 answer

0

Look at an example of One to Many and more examples and documentation at Laravel.com

<?php

class Category extends Eloquent {

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'categories';

    /**
     * Whether or not to enable timestamps.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * Defines a one-to-many relationship.
     *
     * @see http://laravel.com/docs/eloquent#one-to-many
     */
    public function posts()
    {
        return $this->hasMany('Post');
    }

    /**
     * Defines a has-many-through relationship.
     *
     * @see http://laravel.com/docs/eloquent#has-many-through
     */
    public function comments()
    {
        return $this->hasManyThrough('Comment', 'Post');
    }

}
    
30.09.2014 / 13:49