source: app/Models/Artist.php

Last change on this file was dfae77e, checked in by Igor Danilovski <igor_danilovski@…>, 2 years ago
  • Initial commit;
  • Property mode set to 100644
File size: 2.5 KB
Line 
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Factories\HasFactory;
6use Illuminate\Database\Eloquent\Model;
7use Illuminate\Database\Eloquent\Relations\BelongsTo;
8use Illuminate\Database\Eloquent\Relations\BelongsToMany;
9use Illuminate\Database\Eloquent\Relations\HasMany;
10use Illuminate\Database\Eloquent\Relations\HasOne;
11
12class Artist extends User
13{
14 use HasFactory;
15
16 protected $table = 'artists';
17
18 protected $primaryKey = 'user_id';
19
20 public $timestamps = false;
21
22 /**
23 * The attributes that are mass assignable.
24 *
25 * @var array<int, string>
26 */
27 protected $fillable = [
28 'user_id',
29 'city',
30 'country',
31 'short_description',
32 'price_per_hour',
33 'instagram_link',
34 'soundcloud_link',
35 'apple_music_link',
36 'youtube_link',
37 'spotify_link',
38 'manager_id',
39 'artist_type_id',
40 ];
41
42 /**
43 * The attributes that should be cast.
44 *
45 * @var array<string, string>
46 */
47 protected $casts = [
48 'admin_verified_at' => 'datetime',
49 'birth_date' => 'date',
50 ];
51
52 public function isOnboardingCompleted()
53 {
54 return !((is_null($this->birth_date) || trim($this->birth_date) === '') ||
55 (is_null($this->city) || trim($this->city) === '') ||
56 (is_null($this->country) || trim($this->country) === '') ||
57 (is_null($this->short_description) || trim($this->short_description) === '') ||
58 (self::artist_type()->doesntExist()) ||
59 (self::genres()->doesntExist()));
60 }
61
62 public function user(): BelongsTo
63 {
64 return $this->belongsTo(User::class);
65 }
66
67 public function artist_type(): BelongsTo
68 {
69 return $this->belongsTo(ArtistType::class);
70 }
71
72 public function manager(): BelongsTo
73 {
74 return $this->belongsTo(Manager::class, 'manager_id', 'user_id');
75 }
76
77 public function images(): HasMany
78 {
79 return $this->hasMany(ArtistImage::class, 'artist_id');
80 }
81
82 public function genres(): BelongsToMany
83 {
84 return $this->belongsToMany(Genre::class, 'artist_sings_genres', 'artist_id');
85 }
86
87 public function manager_invites(): HasOne
88 {
89 return $this->hasOne(ManagerInvite::class, 'user_id', 'artist_id');
90 }
91
92 public function offers(): HasMany
93 {
94 return $this->hasMany(Offer::class, 'artist_id');
95 }
96
97 public function reviews(): HasMany
98 {
99 return $this->hasMany(Review::class, 'artist_id');
100 }
101}
Note: See TracBrowser for help on using the repository browser.