Project.php
3.42 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
namespace App\Models;
use App\Models\Pivots\UserProjectPivot;
use App\Support\Model;
use Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo;
use Awobaz\Compoships\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Project extends Model
{
use SoftDeletes;
protected $table = 'projects';
protected $guarded = [];
protected $hidden = ['deleted_at'];
protected $casts = [
'is_public' => 'int',
'is_can_apply' => 'int',
'is_can_manage' => 'int',
'is_can_demo_apply' => 'int',
'is_demo_audit' => 'int',
];
public array $columnMap = [
'cover' => '封面',
'name' => '名称',
'intro' => '简介',
'master_id' => '主理人',
'is_promote' => '是否确认分享人',
'is_public' => '是否仅显示自己创建的试唱活动',
'is_can_apply' => '是否允许提交上架申请',
'is_can_manage' => '是否允许自行添加外部成员',
'is_can_demo_apply' => '是否允许提交Demo上架',
'is_demo_audit' => 'Demo上架是否需要审核',
'weight' => '权重值'
];
/**
* @param $value
* @return string
*/
public function getCoverAttribute($value): string
{
return empty($value) ? 'https://hi-sing-cdn.hikoon.com/image/20230925/b2f5im19hc1695620904296trgzs37vx.png' : $value;
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class)->withTrashed();
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo
*/
public function master(): BelongsTo
{
return $this->belongsTo(User::class)->withTrashed();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function managers(): BelongsToMany
{
return $this->belongsToMany(User::class, UserProjectPivot::class);
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
*/
public function members(): HasMany
{
return $this->hasMany(ProjectHasMember::class);
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
*/
public function activities(): HasMany
{
return $this->hasMany(Activity::class)->where('activitys.audit_status', 1);
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
*/
public function totalSong(): HasMany
{
return $this->hasMany(Activity::class)->where('audit_status', 1)->whereNotIn('status', [0, 2, 4]);
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
*/
public function onlineSong(): HasMany
{
return $this->hasMany(Activity::class)->where(['status' => 1, 'audit_status' => 1]);
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne|\Illuminate\Database\Eloquent\Relations\HasOne
*/
public function comfirmTime()
{
return $this->hasOne(ProjectConfirmationTime::class, 'project_id', 'id');
}
public function visitor()
{
return $this->hasMany(ProjectVisitor::class, 'project_id', 'id');
}
}