source: app/Models/User.php@ dfae77e

Last change on this file since dfae77e was dfae77e, checked in by Igor Danilovski <igor_danilovski@…>, 2 years ago
  • Initial commit;
  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[dfae77e]1<?php
2
3namespace App\Models;
4
5use App\Enum\UserType;
6use Illuminate\Contracts\Auth\MustVerifyEmail;
7use Illuminate\Database\Eloquent\Factories\HasFactory;
8use Illuminate\Database\Eloquent\Relations\HasMany;
9use Illuminate\Database\Eloquent\Relations\HasOne;
10use Illuminate\Foundation\Auth\User as Authenticatable;
11use Illuminate\Notifications\Notifiable;
12use Laravel\Cashier\Billable;
13use Laravel\Sanctum\HasApiTokens;
14
15class User extends Authenticatable implements MustVerifyEmail
16{
17 use HasApiTokens, HasFactory, Notifiable, Billable;
18
19 protected $table = 'users';
20
21 /**
22 * The attributes that are mass assignable.
23 *
24 * @var array<int, string>
25 */
26 protected $fillable = [
27 'email',
28 'username',
29 'password',
30 'name',
31 'profile_picture',
32 'type',
33 ];
34
35 /**
36 * The attributes that should be hidden for serialization.
37 *
38 * @var array<int, string>
39 */
40 protected $hidden = [
41 'password',
42 'remember_token',
43 'last_login_at',
44 'last_login_ip',
45 'user_agent',
46 ];
47
48 /**
49 * The attributes that are not mass assignable.
50 * @var string[]
51 */
52 protected $guarded = [
53 'last_login_at',
54 'last_login_ip',
55 'user_agent',
56 ];
57
58 /**
59 * The attributes that should be cast.
60 *
61 * @var array<string, string>
62 */
63 protected $casts = [
64 'email_verified_at' => 'datetime',
65 ];
66
67 public function isOnboardingCompleted()
68 {
69 return true;
70 }
71
72 public function role(): ?HasOne
73 {
74 return match ($this->type) {
75 UserType::ORGANIZER->value => $this->hasOne(Organizer::class),
76 UserType::MANAGER->value => $this->hasOne(Manager::class),
77 UserType::ARTIST->value => $this->hasOne(Artist::class),
78 };
79 }
80
81 public function offer_comments(): HasMany
82 {
83 return $this->hasMany(OfferComment::class, 'author_id');
84 }
85}
Note: See TracBrowser for help on using the repository browser.