]> git.localhorst.tv Git - alttp.git/blob - app/Models/EpisodePlayer.php
refine chat gen
[alttp.git] / app / Models / EpisodePlayer.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 EpisodePlayer extends Model
9 {
10         use HasFactory;
11
12         public function episode() {
13                 return $this->belongsTo(Episode::class);
14         }
15
16         public function user() {
17                 return $this->belongsTo(User::class);
18         }
19
20         public function getName() {
21                 if (!empty($this->name_override)) {
22                         return $this->name_override;
23                 }
24                 if ($this->user) {
25                         if (!empty($this->user->nickname)) {
26                                 return $this->user->nickname;
27                         }
28                         if (!empty($this->user->username)) {
29                                 return $this->user->username;
30                         }
31                 }
32                 return '';
33         }
34
35         public function getStreamLink() {
36                 if (!empty($this->stream_override)) {
37                         return $this->stream_override;
38                 }
39                 if ($this->user && !empty($this->user->stream_link)) {
40                         return $this->user->stream_link;
41                 }
42                 return '';
43         }
44
45         protected $casts = [
46                 'user_id' => 'string',
47         ];
48
49         protected $hidden = [
50                 'created_at',
51                 'ext_id',
52                 'updated_at',
53         ];
54
55 }