1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Models;
|
---|
4 |
|
---|
5 | use Illuminate\Database\Eloquent\Factories\HasFactory;
|
---|
6 | use Illuminate\Database\Eloquent\Model;
|
---|
7 | use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
---|
8 | use Illuminate\Database\Eloquent\Relations\HasMany;
|
---|
9 | use Laravel\Cashier\Billable;
|
---|
10 |
|
---|
11 | class Organizer extends User
|
---|
12 | {
|
---|
13 | use HasFactory;
|
---|
14 |
|
---|
15 | protected $table = 'organizers';
|
---|
16 |
|
---|
17 | protected $primaryKey = 'user_id';
|
---|
18 |
|
---|
19 | public $timestamps = false;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * The attributes that are mass assignable.
|
---|
23 | *
|
---|
24 | * @var array<int, string>
|
---|
25 | */
|
---|
26 | protected $fillable = [
|
---|
27 | 'user_id',
|
---|
28 | 'city',
|
---|
29 | 'country',
|
---|
30 | 'stripe_id',
|
---|
31 | 'card_brand',
|
---|
32 | 'card_last_four',
|
---|
33 | ];
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * The attributes that should be hidden for serialization.
|
---|
37 | *
|
---|
38 | * @var array<int, string>
|
---|
39 | */
|
---|
40 | protected $hidden = [
|
---|
41 | 'stripe_id',
|
---|
42 | 'card_brand',
|
---|
43 | 'card_last_four',
|
---|
44 | ];
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * The attributes that should be cast.
|
---|
48 | *
|
---|
49 | * @var array<string, string>
|
---|
50 | */
|
---|
51 | protected $casts = [
|
---|
52 | 'trial_ends_at' => 'datetime',
|
---|
53 | ];
|
---|
54 |
|
---|
55 | public function isOnboardingCompleted()
|
---|
56 | {
|
---|
57 | return !((is_null($this->city) || trim($this->city) === '') ||
|
---|
58 | (is_null($this->country) || trim($this->country) === ''));
|
---|
59 | }
|
---|
60 |
|
---|
61 | public function user(): BelongsTo
|
---|
62 | {
|
---|
63 | return $this->belongsTo(User::class);
|
---|
64 | }
|
---|
65 |
|
---|
66 | public function events(): HasMany
|
---|
67 | {
|
---|
68 | return $this->hasMany(Event::class, 'organizer_id');
|
---|
69 | }
|
---|
70 |
|
---|
71 | public function reviews(): HasMany
|
---|
72 | {
|
---|
73 | return $this->hasMany(Review::class, 'organizer_id');
|
---|
74 | }
|
---|
75 | }
|
---|