Files
newznab-tmux/app/Providers/ForumServiceProvider.php
T
2026-02-26 14:26:07 +01:00

32 lines
637 B
PHP

<?php
declare(strict_types=1);
namespace App\Providers;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\ServiceProvider;
use TeamTeaTime\Forum\Models\Post;
class ForumServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// Add global scope to eager load author with role for all post queries
Post::addGlobalScope('withAuthorRole', function (Builder $builder) {
$builder->with(['author.role']);
});
}
}