45 lines
1 KiB
PHP
45 lines
1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @method static create(array $validated)
|
||
|
|
* @property PlatformInstance $platformInstance
|
||
|
|
*/
|
||
|
|
class Community extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'platform_instance_id',
|
||
|
|
'name',
|
||
|
|
'display_name',
|
||
|
|
'community_id',
|
||
|
|
'description',
|
||
|
|
'is_active'
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'is_active' => 'boolean'
|
||
|
|
];
|
||
|
|
|
||
|
|
public function platformInstance(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(PlatformInstance::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function platformAccounts(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(PlatformAccount::class, 'account_communities')
|
||
|
|
->withPivot(['is_active', 'priority'])
|
||
|
|
->withTimestamps();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getFullNameAttribute(): string
|
||
|
|
{
|
||
|
|
return $this->platformInstance->url . '/c/' . $this->name;
|
||
|
|
}
|
||
|
|
}
|