lasthourcloud/app/Providers/AppServiceProvider.php

34 lines
1011 B
PHP
Raw Permalink Normal View History

2023-03-17 14:33:48 +00:00
<?php
namespace App\Providers;
2023-05-30 13:52:17 +00:00
use Illuminate\Support\Facades\Http;
2023-03-17 14:33:48 +00:00
use Illuminate\Support\ServiceProvider;
2023-10-18 16:02:09 +00:00
use Laravel\Sanctum\Sanctum;
use App\Models\PersonalAccessToken;
2023-03-17 14:33:48 +00:00
class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
}
public function boot(): void
{
2023-10-18 16:02:09 +00:00
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
2023-06-13 13:01:11 +00:00
Http::macro('github', function (string $api_url, string|null $github_access_token = null) {
if ($github_access_token) {
return Http::withHeaders([
'X-GitHub-Api-Version' => '2022-11-28',
'Accept' => 'application/vnd.github.v3+json',
'Authorization' => "Bearer $github_access_token",
])->baseUrl($api_url);
} else {
return Http::withHeaders([
'Accept' => 'application/vnd.github.v3+json',
])->baseUrl($api_url);
}
2023-05-30 13:52:17 +00:00
});
2023-03-17 14:33:48 +00:00
}
}