]> git.localhorst.tv Git - alttp.git/blob - app/Models/EpisodeCrew.php
switch SNES default port
[alttp.git] / app / Models / EpisodeCrew.php
1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Database\Eloquent\Model;
7
8 class EpisodeCrew extends Model
9 {
10         use HasFactory;
11
12         public function channel() {
13                 return $this->belongsTo(Channel::class);
14         }
15
16         public function episode() {
17                 return $this->belongsTo(Episode::class);
18         }
19
20         public function user() {
21                 return $this->belongsTo(User::class);
22         }
23
24         public function getName() {
25                 if (!empty($this->name_override)) {
26                         return $this->name_override;
27                 }
28                 if ($this->user) {
29                         if (!empty($this->user->nickname)) {
30                                 return $this->user->nickname;
31                         }
32                         if (!empty($this->user->username)) {
33                                 return $this->user->username;
34                         }
35                 }
36                 return '';
37         }
38
39         public function getStreamLink() {
40                 if (!empty($this->stream_override)) {
41                         return $this->stream_override;
42                 }
43                 if ($this->user && !empty($this->user->stream_link)) {
44                         return $this->user->stream_link;
45                 }
46                 return '';
47         }
48
49         protected $casts = [
50                 'confirmed' => 'boolean',
51                 'user_id' => 'string',
52         ];
53
54         protected $fillable = [
55                 'channel_id',
56                 'episode_id',
57                 'role',
58                 'user_id',
59         ];
60
61         protected $hidden = [
62                 'created_at',
63                 'ext_id',
64                 'updated_at',
65         ];
66
67 }