Skip to content

Instantly share code, notes, and snippets.

@vanessasoutoc
Last active April 7, 2017 16:40
Show Gist options
  • Save vanessasoutoc/3cd5ae6bd5d4213f0d7ebd0c5143b0bb to your computer and use it in GitHub Desktop.
Save vanessasoutoc/3cd5ae6bd5d4213f0d7ebd0c5143b0bb to your computer and use it in GitHub Desktop.
model com relacionamentos
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'admin', 'associado', 'cpf', 'nascimento', 'telefone', 'address_id', 'plano_id', 'cartao_id', 'indicacao_id'
];
public function noticias(){
return $this->hasMany('\App\Noticia');
}
public function contribuicoes(){
return $this->hasMany('\App\Contribuicao');
}
//USUÁRIO TEM UM FK_ADDRESS
public function address(){
return $this->belongsTo("\App\Address", 'address_id');
}
//USUÁRIO TEM UM FK_PLANO
public function plano(){
return $this->belongsTo("\App\Plano", 'plano_id');
}
public function cartao(){
return $this->belongsTo("\App\Cartao", 'cartao_id');
}
public $timestamps = true;
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment