*/ protected $fillable = ['name', 'email', 'password', 'document', 'type', 'status', 'curso_id', 'unidade_id']; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = ['password', 'remember_token']; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime' ]; /** * Validar os campos de acordo com as regras implementadas * */ public static function validator($attributes) { $rules = [ 'email' => ['required', 'email', ], 'name' => ['required', ] ]; $messages = [ // 'unique' => "O :attribute já está registrado no sistema", 'required' => "O :attribute precisa ser preenchido", ]; try { return Validator::make($attributes, $rules, $messages); } catch(ValidationException $exception) { } } /** * Get Curso with curso.id = user.curso_id * * @return Curso|null */ public function curso() { return $this->belongsTo(Curso::class); } /** * Get Unidade with unidade.id = user.unidade_id * * @return Unidade|null */ public function unidade() { return $this->belongsTo(Unidade::class); } /** * @return bool */ public function isTypeAdmin() { return $this->type === self::TYPE_ADMIN; } /** * @return bool */ public function isTypeTeacher() { return $this->type === self::TYPE_TEACHER; } /** * @return bool */ public function isTypeMenager() { return $this->type === self::TYPE_MANAGER; } /** * @return bool */ public function isTypeCoordinator() { return $this->type === self::TYPE_COORDINATOR; } /** * @return string */ public function attributeName(string $attribute) { return $this->getTable() . '-' . $attribute; } /** * @return string */ public function __toString() { return $this->name; } }