Skip to content

Instantly share code, notes, and snippets.

@betinho37
Created May 25, 2018 16:26
Show Gist options
  • Select an option

  • Save betinho37/da6c4493b234856d2700a75d09eedfee to your computer and use it in GitHub Desktop.

Select an option

Save betinho37/da6c4493b234856d2700a75d09eedfee to your computer and use it in GitHub Desktop.
Models
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Estado extends Model
{
protected $fillable = ['sigla', 'descricao'];
public static function listEstados()
{
return static::orderBy('sigla')->pluck('sigla', 'id');
}
}
<?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 $table = 'users';
protected $fillable = [
'name',
'email',
'password',
'cep',
'uf',
'endereco',
'telefone',
'tipousuario',
'estadoid',
'relacaoid'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
public static function listUser()
{
return static::orderBy('name')->pluck('name', 'id');
}
public function estado()
{
return $this->belongsTo('App\Estado', 'estadoid');
}
protected $hidden = [
'password', 'remember_token',
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment