lasthourcloud/app/Providers/AppServiceProvider.php

39 lines
1.2 KiB
PHP
Raw Normal View History

2023-03-17 14:33:48 +00:00
<?php
namespace App\Providers;
use App\Models\InstanceSettings;
2024-06-10 20:43:34 +00:00
use App\Models\PersonalAccessToken;
2023-05-30 13:52:17 +00:00
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\View;
2023-03-17 14:33:48 +00:00
use Illuminate\Support\ServiceProvider;
2023-10-18 16:02:09 +00:00
use Laravel\Sanctum\Sanctum;
2023-03-17 14:33:48 +00:00
class AppServiceProvider extends ServiceProvider
{
2024-06-19 06:59:46 +00:00
public function register(): void {}
2023-03-17 14:33:48 +00:00
public function boot(): void
{
2023-10-18 16:02:09 +00:00
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
2024-07-12 10:59:53 +00:00
2024-06-10 20:43:34 +00:00
Http::macro('github', function (string $api_url, ?string $github_access_token = null) {
2023-06-13 13:01:11 +00:00
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
});
2024-07-12 13:45:36 +00:00
// if (! env('CI')) {
// View::share('instanceSettings', InstanceSettings::get());
// }
2023-03-17 14:33:48 +00:00
}
}