demo/app/Modules/Settings/Models/Prefix.php
2023-03-23 18:50:47 +01:00

62 lines
1.3 KiB
PHP

<?php
namespace LaraBB\Settings\Models;
use App\Traits\Uuid;
use App\Traits\Who;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use LaraBB\Forum\Models\Forum;
use LaraBB\Thread\Models\Thread;
/**
* Class Prefix
*
* @property int $id
* @property string $uuid
* @property Carbon $created_at
* @property string $created_uuid
* @property Carbon $updated_at
* @property string $updated_uuid
* @property string $prefix
* @property string $display_style
* @property Collection $forums
* @property Collection $threads
*
* @package LaraBB\Settings\Models
*/
class Prefix extends Model
{
use Uuid;
use Who;
protected $withCount = [
'threads'
];
/**
* @var string
*/
protected $table = 'settings_prefixes';
/**
* @var string
*/
protected $primaryKey = 'uuid';
/**
* @return BelongsToMany
*/
public function forums(): BelongsToMany
{
return $this->belongsToMany(Forum::class, 'forums_has_prefixes', 'prefix_uuid', 'forum_uuid');
}
public function threads(): HasMany
{
return $this->hasMany(Thread::class, 'prefix_uuid', 'uuid');
}
}