Files
RomhackPlaza/app/Models/Author.php

31 lines
658 B
PHP
Raw Normal View History

2026-05-20 18:25:15 +02:00
<?php
namespace App\Models;
2026-06-08 16:25:52 +02:00
use App\Auth\XenForoUser;
use App\Services\XenforoService;
2026-05-20 18:25:15 +02:00
use Illuminate\Database\Eloquent\Model;
2026-06-08 16:25:52 +02:00
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
2026-05-20 18:25:15 +02:00
class Author extends Model
{
protected $fillable = [
'name', 'slug', 'user_id', 'website'
];
2026-06-08 16:25:52 +02:00
public function entries(): BelongsToMany
{
return $this->belongsToMany(Entry::class, 'entry_authors');
}
public function user(): ?XenForoUser
{
if( !$this->user_id )
return null;
return app(XenforoService::class)->getXfUser($this->user_id);
}
2026-05-20 18:25:15 +02:00
}