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
?
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
?
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');
}
}