31 lines
655 B
PHP
31 lines
655 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Player;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// 仅在通过 EnsurePlayerApi 后可用;未走中间件时为 null
|
|
Request::macro('lotteryPlayer', function (): ?Player {
|
|
/** @var Request $this */
|
|
return $this->attributes->get('lottery_player');
|
|
});
|
|
}
|
|
}
|