2021-04-02 19:48:41 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2022-07-19 13:28:04 +08:00
|
|
|
use App\Http\Middleware\Locale;
|
2022-06-27 01:39:01 +08:00
|
|
|
use Carbon\Carbon;
|
2024-12-25 23:09:07 +08:00
|
|
|
use Filament\Support\Assets\Css;
|
|
|
|
|
use Filament\Support\Facades\FilamentAsset;
|
2025-05-19 13:18:47 +07:00
|
|
|
use Illuminate\Contracts\Events\Dispatcher;
|
|
|
|
|
use Illuminate\Console\Events\ScheduledTaskStarting;
|
2021-04-28 19:44:48 +08:00
|
|
|
use Illuminate\Support\Facades\App;
|
2021-04-26 20:37:17 +08:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2024-11-11 18:22:54 +08:00
|
|
|
use Illuminate\Support\Facades\URL;
|
2022-09-08 19:14:01 +08:00
|
|
|
use Illuminate\Support\Facades\View;
|
2021-04-02 19:48:41 +08:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
2024-03-17 02:39:26 +08:00
|
|
|
use Laravel\Passport\Passport;
|
2025-03-29 14:32:31 +07:00
|
|
|
use Nexus\Database\NexusDB;
|
2022-03-20 22:14:00 +08:00
|
|
|
use Nexus\Nexus;
|
2022-06-27 01:39:01 +08:00
|
|
|
use Filament\Facades\Filament;
|
2021-04-02 19:48:41 +08:00
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function register()
|
|
|
|
|
{
|
2022-08-04 00:48:42 +08:00
|
|
|
do_action('nexus_register');
|
2021-04-02 19:48:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function boot()
|
|
|
|
|
{
|
2024-08-24 06:49:55 +08:00
|
|
|
global $plugin;
|
|
|
|
|
$plugin->start();
|
2025-03-29 14:32:31 +07:00
|
|
|
NexusDB::customModel();
|
2021-04-26 20:37:17 +08:00
|
|
|
DB::connection(config('database.default'))->enableQueryLog();
|
2024-11-11 18:22:54 +08:00
|
|
|
$forceScheme = strtolower(env('FORCE_SCHEME'));
|
|
|
|
|
if (env('APP_ENV') == "production" && in_array($forceScheme, ['https', 'http'])) {
|
|
|
|
|
URL::forceScheme($forceScheme);
|
|
|
|
|
}
|
2025-05-19 13:18:47 +07:00
|
|
|
$this->customScheduleTask();
|
2022-04-09 01:54:40 +08:00
|
|
|
|
2022-06-27 01:39:01 +08:00
|
|
|
Filament::serving(function () {
|
|
|
|
|
Filament::registerNavigationGroups([
|
|
|
|
|
'User',
|
|
|
|
|
'Torrent',
|
2025-10-04 15:31:46 +07:00
|
|
|
'Tracker',
|
2022-12-20 22:24:31 +08:00
|
|
|
'Role & Permission',
|
2022-08-11 13:48:26 +08:00
|
|
|
'Other',
|
2022-10-27 20:21:54 +08:00
|
|
|
'Section',
|
2024-03-11 02:12:17 +08:00
|
|
|
'Oauth',
|
2022-06-27 01:39:01 +08:00
|
|
|
'System',
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
2024-12-25 23:09:07 +08:00
|
|
|
FilamentAsset::register([
|
|
|
|
|
Css::make("sprites", asset('styles/sprites.css')),
|
|
|
|
|
Css::make("admin", asset('styles/admin.css')),
|
2022-08-13 01:01:17 +08:00
|
|
|
]);
|
|
|
|
|
|
2022-08-04 00:48:42 +08:00
|
|
|
do_action('nexus_boot');
|
2021-04-02 19:48:41 +08:00
|
|
|
}
|
2025-05-19 13:18:47 +07:00
|
|
|
|
|
|
|
|
private function customScheduleTask(): void
|
|
|
|
|
{
|
|
|
|
|
if (!isRunningInConsole()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/** @var Dispatcher $eventDispatcher */
|
|
|
|
|
$eventDispatcher = $this->app->make(Dispatcher::class);
|
|
|
|
|
|
|
|
|
|
$eventDispatcher->listen(
|
|
|
|
|
events: [ScheduledTaskStarting::class],
|
|
|
|
|
listener: static function (ScheduledTaskStarting $event): void {
|
|
|
|
|
$event->task->onOneServer()->withoutOverlapping();
|
|
|
|
|
// When we are using stterr as output for logs then schedule tasks will not output
|
|
|
|
|
// any logs due the /dev/null usage. Let's fix this by appending the output to
|
|
|
|
|
// the docker process.
|
|
|
|
|
if (getenv("RUNNING_IN_DOCKER") == "1" && $event->task->output === $event->task->getDefaultOutput()) {
|
|
|
|
|
$event->task->appendOutputTo("/proc/1/fd/1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-04-02 19:48:41 +08:00
|
|
|
}
|