1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Providers/AppServiceProvider.php

138 lines
4.2 KiB
PHP
Raw Normal View History

2018-10-04 19:10:43 +02:00
<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 05:32:07 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2019-05-11 05:32:07 +02:00
*/
2018-10-04 19:10:43 +02:00
namespace App\Providers;
2021-05-23 23:53:30 +02:00
use App\Http\Middleware\SetDomainNameDb;
2019-04-20 00:27:37 +02:00
use App\Models\Account;
use App\Models\Client;
use App\Models\Company;
2020-08-22 02:42:12 +02:00
use App\Models\CompanyGateway;
2019-04-20 00:27:37 +02:00
use App\Models\CompanyToken;
2021-02-15 11:52:50 +01:00
use App\Models\Credit;
2019-04-20 00:27:37 +02:00
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Product;
use App\Models\Proposal;
use App\Models\Quote;
2021-05-23 23:53:30 +02:00
use App\Models\Subscription;
2019-04-20 00:27:37 +02:00
use App\Models\Task;
use App\Models\User;
use App\Observers\AccountObserver;
use App\Observers\ClientObserver;
2020-08-22 02:42:12 +02:00
use App\Observers\CompanyGatewayObserver;
2019-04-20 00:27:37 +02:00
use App\Observers\CompanyObserver;
use App\Observers\CompanyTokenObserver;
2021-02-15 11:52:50 +01:00
use App\Observers\CreditObserver;
2019-04-20 00:27:37 +02:00
use App\Observers\ExpenseObserver;
use App\Observers\InvoiceObserver;
use App\Observers\PaymentObserver;
use App\Observers\ProductObserver;
use App\Observers\ProposalObserver;
use App\Observers\QuoteObserver;
2021-05-23 23:53:30 +02:00
use App\Observers\SubscriptionObserver;
2019-04-20 00:27:37 +02:00
use App\Observers\TaskObserver;
use App\Observers\UserObserver;
2021-05-23 23:53:30 +02:00
use App\Utils\Ninja;
2021-02-08 11:11:17 +01:00
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Database\Eloquent\Relations\Relation;
2020-08-11 02:48:05 +02:00
use Illuminate\Queue\Events\JobProcessing;
use Illuminate\Support\Facades\Blade;
2020-08-11 02:48:05 +02:00
use Illuminate\Support\Facades\Queue;
2021-02-08 11:11:17 +01:00
use Illuminate\Support\Facades\RateLimiter;
2019-04-20 00:14:52 +02:00
use Illuminate\Support\Facades\Schema;
2018-10-04 19:10:43 +02:00
use Illuminate\Support\ServiceProvider;
2021-05-23 23:53:30 +02:00
use Livewire\Livewire;
2018-10-04 19:10:43 +02:00
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
2021-02-08 11:11:17 +01:00
/* Limits the number of parallel jobs fired per minute when checking data*/
RateLimiter::for('checkdata', function ($job) {
return Limit::perMinute(100);
});
Relation::morphMap([
2020-10-28 11:10:49 +01:00
'invoices' => Invoice::class,
2020-09-22 08:11:32 +02:00
// 'credits' => \App\Models\Credit::class,
2020-10-28 11:10:49 +01:00
'proposals' => Proposal::class,
]);
Blade::if('env', function ($environment) {
return config('ninja.environment') === $environment;
});
2019-04-20 00:14:52 +02:00
Schema::defaultStringLength(191);
2019-04-20 00:27:37 +02:00
Account::observe(AccountObserver::class);
Subscription::observe(SubscriptionObserver::class);
2019-04-20 00:27:37 +02:00
Client::observe(ClientObserver::class);
Company::observe(CompanyObserver::class);
2020-08-22 02:42:12 +02:00
CompanyGateway::observe(CompanyGatewayObserver::class);
2019-04-20 00:27:37 +02:00
CompanyToken::observe(CompanyTokenObserver::class);
2021-02-15 11:52:50 +01:00
Credit::observe(CreditObserver::class);
2019-04-20 00:27:37 +02:00
Expense::observe(ExpenseObserver::class);
Invoice::observe(InvoiceObserver::class);
Payment::observe(PaymentObserver::class);
Product::observe(ProductObserver::class);
Proposal::observe(ProposalObserver::class);
Quote::observe(QuoteObserver::class);
Task::observe(TaskObserver::class);
2021-03-05 11:18:28 +01:00
User::observe(UserObserver::class);
2021-05-23 23:53:30 +02:00
/* Handles setting the correct database with livewire classes */
if(Ninja::isHosted())
{
Livewire::addPersistentMiddleware([
SetDomainNameDb::class,
]);
}
// Queue::before(function (JobProcessing $event) {
// // \Log::info('Event Job '.$event->connectionName);
// \Log::error('Event Job '.$event->job->getJobId);
// // \Log::info('Event Job '.$event->job->payload());
// });
//! Update Posted AT
// Queue::after(function (JobProcessed $event) {
// // \Log::info('Event Job '.$event->connectionName);
// \Log::error('Event Job '.$event->job->getJobId);
// // \Log::info('Event Job '.$event->job->payload());
// });
2018-10-04 19:10:43 +02:00
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->loadHelpers();
}
protected function loadHelpers()
{
foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) {
require_once $filename;
}
2018-10-04 19:10:43 +02:00
}
}