Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/TimesheetServiceProvider.php
<?php

namespace Corals\Modules\Timesheet;


use Corals\Foundation\Facades\Filters;
use Corals\Modules\Timesheet\Facades\Timesheet;
use Corals\Modules\Timesheet\Hooks\Timesheet as TimesheetHooks;
use Corals\Modules\Timesheet\Models\Client;
use Corals\Modules\Timesheet\Notifications\ProjectBudgetExceedsNotification;
use Corals\Modules\Timesheet\Notifications\TimeOffRequestApprovedNotification;
use Corals\Modules\Timesheet\Notifications\TimeOffRequestNotification;
use Corals\Modules\Timesheet\Notifications\TimeOffRequestRejectedNotification;
use Corals\Modules\Timesheet\Providers\TimesheetAuthServiceProvider;
use Corals\Modules\Timesheet\Providers\TimesheetObserverServiceProvider;
use Corals\Modules\Timesheet\Providers\TimesheetRouteServiceProvider;
use Corals\Modules\Utility\Facades\Utility;
use Corals\Modules\Utility\Facades\Webhook\Webhooks;
use Corals\Settings\Facades\Settings;
use Corals\User\Communication\Facades\CoralsNotification;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider;


class TimesheetServiceProvider extends ServiceProvider
{
    protected $defer = true;

    /**
     * Bootstrap the application events.
     *
     * @return void
     */

    public function boot()
    {
        // Load view
        $this->loadViewsFrom(__DIR__ . '/resources/views', 'Timesheet');

        // Load translation
        $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'Timesheet');

        // Load migrations
//        $this->loadMigrationsFrom(__DIR__ . '/database/migrations');

        $this->registerCustomFieldsModels();

        $this->registerCreateRestPasswordUrlCallback();

        Filters::add_filter('users_alerts', [TimesheetHooks::class, 'usersAlert'], 15);

        Utility::addToUtilityModules('Timesheet');

        $this->addEvents();

        $this->registerWebhooks();

    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->mergeConfigFrom(__DIR__ . '/config/timesheet.php', 'timesheet');
        $this->mergeConfigFrom(__DIR__ . '/Integration/JIRA/config.php', 'ts_jira');

        $this->app->register(TimesheetRouteServiceProvider::class);
        $this->app->register(TimesheetAuthServiceProvider::class);
        $this->app->register(TimesheetObserverServiceProvider::class);

        $this->app->booted(function () {
            $loader = AliasLoader::getInstance();
            $loader->alias('Timesheet', Timesheet::class);
        });
    }

    protected function registerCustomFieldsModels()
    {
        Settings::addCustomFieldModel(Client::class);
    }

    protected function addEvents()
    {
        CoralsNotification::addEvent(
            'notifications.time_off_request.request',
            'New Time Off Request',
            TimeOffRequestNotification::class,
            'notifications.time_off_request.request');

        CoralsNotification::addEvent(
            'notifications.time_off_request.approved',
            'Time off Request Approved',
            TimeOffRequestApprovedNotification::class,
            'notifications.time_off_request.approved');

        CoralsNotification::addEvent(
            'notifications.time_off_request.rejected',
            'Time off Request Rejected',
            TimeOffRequestRejectedNotification::class,
            'notifications.time_off_request.rejected');

        CoralsNotification::addEvent(
            'notifications.project_budget.exceed',
            'Project Budget Exceed',
            ProjectBudgetExceedsNotification::class,
            'notifications.project_budget.exceed');
    }

    /**
     *
     */
    protected function registerCreateRestPasswordUrlCallback()
    {
        ResetPassword::createUrlUsing(function ($notifiable, $token) {
            $queryString = http_build_query([
                'email' => $notifiable->getEmailForPasswordReset()
            ]);

            return sprintf("%s/password/reset/%s?%s", rtrim(config('timesheet.frontend_app_url'), '/'), $token,
                $queryString);
        });
    }

    protected function registerWebhooks()
    {
        foreach (config('timesheet.webhook.events', []) as $eventName => $jobClass) {
            Webhooks::registerEvent($eventName, $jobClass);
        }
    }

}

Spamworldpro Mini