LaravelTest
70 строк · 1.5 Кб
1<?php
2
3namespace App\Models;
4
5// use Illuminate\Contracts\Auth\MustVerifyEmail;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Foundation\Auth\User as Authenticatable;
8use Illuminate\Notifications\Notifiable;
9
10class User extends Authenticatable
11{
12use HasFactory, Notifiable;
13
14/**
15* The attributes that are mass assignable.
16*
17* @var array<int, string>
18*/
19
20protected $table = 'users';
21protected $guarded = false;
22
23
24const GENDER_MALE = 1;
25const GENDER_FEMALE = 2;
26
27static function getGenders() {
28return [
29self::GENDER_MALE => 'Мужской',
30self::GENDER_FEMALE => 'Женский',
31];
32}
33//создание геттера genderTitle
34public function getGenderTitleAttribute() {
35return self::getGenders()[$this->gender];
36}
37
38
39/**
40* The attributes that should be hidden for serialization.
41*
42* @var array<int, string>
43*/
44protected $hidden = [
45'password',
46'remember_token',
47];
48protected $fillable = [
49'name',
50'surname',
51'email',
52'password',
53'patronimic',
54'age',
55'gender',
56'address'
57];
58/**
59* Get the attributes that should be cast.
60*
61* @return array<string, string>
62*/
63protected function casts(): array
64{
65return [
66'email_verified_at' => 'datetime',
67'password' => 'hashed',
68];
69}
70}