mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-15 02:07:56 -04:00
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Frontend\Entities;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
class Creator extends User
|
|
{
|
|
protected $table = 'users';
|
|
protected $appends = [
|
|
'default_avatar',
|
|
'ott_photo',
|
|
];
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
static::addGlobalScope('type', function (Builder $builder) {
|
|
$builder
|
|
->whereHas('staff')
|
|
->whereHas('role', function ($query) {
|
|
$query->whereHas('permissions', function ($query) {
|
|
$permissions = [
|
|
'studio-plus.can_upload_video',
|
|
];
|
|
|
|
$query->whereIn('route', $permissions);
|
|
});
|
|
})
|
|
->where('is_active', true);
|
|
});
|
|
}
|
|
|
|
public function getDefaultAvatarAttribute()
|
|
{
|
|
return getUserImageInitial($this->id, $this->name);
|
|
}
|
|
|
|
public function getAvatarAttribute($value)
|
|
{
|
|
if ($value) {
|
|
return asset("public/{$value}");
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
|
|
public function getOttPhotoAttribute()
|
|
{
|
|
if ($this->staff && $this->staff->ott_photo) {
|
|
return asset("public/{$this->staff->ott_photo}");
|
|
} else if ($this->avatar) {
|
|
return $this->avatar;
|
|
}
|
|
|
|
return $this->default_avatar;
|
|
}
|
|
}
|