75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace LaraBB\Group\Models;
|
|
|
|
use App\Traits\Who;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Carbon;
|
|
use App\Traits\Uuid;
|
|
use LaraBB\Forum\Models\Permission;
|
|
use LaraBB\User\Models\User;
|
|
|
|
/**
|
|
* Class Group
|
|
*
|
|
* @property int $id
|
|
* @property string $uuid
|
|
* @property Carbon $created_at
|
|
* @property string $created_uuid
|
|
* @property Carbon $updated_at
|
|
* @property string $updated_uuid
|
|
* @property string $group
|
|
* @property string $color
|
|
* @property int $priority
|
|
* @property Collection $users
|
|
* @property Collection $permissions
|
|
* @property-read int|null $permissions_count
|
|
* @method static Builder|Group newModelQuery()
|
|
* @method static Builder|Group newQuery()
|
|
* @method static Builder|Group query()
|
|
* @method static Builder|Group whereCreatedAt($value)
|
|
* @method static Builder|Group whereCreatedUuid($value)
|
|
* @method static Builder|Group whereGroup($value)
|
|
* @method static Builder|Group whereId($value)
|
|
* @method static Builder|Group wherePriority($value)
|
|
* @method static Builder|Group whereUpdatedAt($value)
|
|
* @method static Builder|Group whereUpdatedUuid($value)
|
|
* @method static Builder|Group whereUuid($value)
|
|
*
|
|
* @package LaraBB\User\Models
|
|
*/
|
|
class Group extends Model
|
|
{
|
|
use Uuid;
|
|
use Who;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $table = 'groups';
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'uuid';
|
|
|
|
/**
|
|
* @return BelongsToMany
|
|
*/
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class, 'users_has_groups', 'group_uuid', 'user_uuid');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function permissions(): HasMany
|
|
{
|
|
return $this->hasMany(Permission::class, 'group_uuid', 'uuid');
|
|
}
|
|
}
|