Initialer Laravel Commit für BetiX
This commit is contained in:
43
app/Models/Guild.php
Normal file
43
app/Models/Guild.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Guild extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'tag',
|
||||
'logo_url',
|
||||
'description',
|
||||
'owner_id',
|
||||
'invite_code',
|
||||
'points',
|
||||
'members_count',
|
||||
];
|
||||
|
||||
/**
|
||||
* Der User, dem die Gilde gehört.
|
||||
*/
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Mitglieder der Gilde (Verknüpfung zu Users über die Pivot-Tabelle).
|
||||
* Dies ermöglicht die Nutzung von attach(), detach() und sync().
|
||||
*/
|
||||
public function members(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'guild_members')
|
||||
->withPivot('role', 'joined_at')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user