mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Spatie\Sheets\Sheets;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The path to your application's "home" route.
|
|
*
|
|
* Typically, users are redirected here after authentication.
|
|
*
|
|
* @var string
|
|
*/
|
|
public const HOME = '/home';
|
|
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if (config('app.env') === 'production') {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
$this->bootAuth();
|
|
$this->bootRoute();
|
|
}
|
|
|
|
public function bootAuth(): void
|
|
{
|
|
Gate::define('viewPulse', fn(User $user) => $user->admin);
|
|
}
|
|
|
|
public function bootRoute(): void
|
|
{
|
|
RateLimiter::for('api', fn(Request $request) => Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()));
|
|
|
|
Route::bind('post', fn($path) => $this->app->make(Sheets::class)
|
|
->collection('posts')
|
|
->get($path) ?? abort(404));
|
|
}
|
|
}
|