Created
May 25, 2018 16:26
-
-
Save betinho37/da6c4493b234856d2700a75d09eedfee to your computer and use it in GitHub Desktop.
Models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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'); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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