-
Notifications
You must be signed in to change notification settings - Fork 96
/
_models.php
71 lines (56 loc) · 1.6 KB
/
_models.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class User extends Illuminate\Database\Eloquent\Model {
protected $table = 'users';
public function categories()
{
return $this->belongsToMany('Category');
}
public function getCategoryNamesAttribute()
{
$return = "";
$prefix = '';
foreach($this->categories as $category)
{
$return .= $prefix . ' ' . $category->name . '';
$prefix = ', ';
}
return $return;
}
public function laststream()
{
return $this->hasOne('Stream', 'id', 'last_stream');
}
}
class Stream extends Illuminate\Database\Eloquent\Model {
public function category()
{
return $this->hasOne('Category', 'id', 'cat_id');
}
public function transcode()
{
return $this->hasOne('Transcode', 'id', 'trans_id');
}
public function getStatusLabelAttribute()
{
$return = [];
$return['label'] = 'important';
$return['text'] = 'STOPPED';
if ($this->status == '1') {
$return['label'] = 'success';
$return['text'] = 'RUNNING';
} else if ($this->status == '2') {
$return['label'] = 'important';
$return['text'] = 'ERROR';
}
return $return;
}
}
class Category extends Illuminate\Database\Eloquent\Model {
public function streams()
{
return $this->hasMany('Stream', 'cat_id', 'id');
}
}
class Admin extends Illuminate\Database\Eloquent\Model { }
class Setting extends Illuminate\Database\Eloquent\Model { }
class Transcode extends Illuminate\Database\Eloquent\Model { }