mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
19080933b6
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the code style applied by adding a [PHP CS Fixer][1] or [PHP CodeSniffer][2] ruleset to your project root. Feel free to use [Shift's Laravel ruleset][3] to help you get started. For more information on customizing the code style applied by Shift, [watch this short video][4]. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://github.com/squizlabs/PHP_CodeSniffer [3]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 [4]: https://laravelshift.com/videos/shift-code-style
94 lines
2.4 KiB
PHP
94 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Http\Middleware\SetDomainNameDb;
|
|
use App\Models\Invoice;
|
|
use App\Models\Proposal;
|
|
use App\Utils\Ninja;
|
|
use App\Utils\TruthSource;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
use Illuminate\Queue\Events\JobProcessing;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\Facades\Queue;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Livewire\Livewire;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
|
|
/* Limits the number of parallel jobs fired per minute when checking data*/
|
|
RateLimiter::for('checkdata', function ($job) {
|
|
return Limit::perMinute(100);
|
|
});
|
|
|
|
Relation::morphMap([
|
|
'invoices' => Invoice::class,
|
|
// 'credits' => \App\Models\Credit::class,
|
|
'proposals' => Proposal::class,
|
|
]);
|
|
|
|
Blade::if('env', function ($environment) {
|
|
return config('ninja.environment') === $environment;
|
|
});
|
|
|
|
Schema::defaultStringLength(191);
|
|
|
|
/* Handles setting the correct database with livewire classes */
|
|
if (Ninja::isHosted()) {
|
|
Livewire::addPersistentMiddleware([
|
|
SetDomainNameDb::class,
|
|
]);
|
|
}
|
|
|
|
/* Ensure we don't have stale state in jobs */
|
|
Queue::before(function (JobProcessing $event) {
|
|
App::forgetInstance('truthsource');
|
|
});
|
|
|
|
app()->instance(TruthSource::class, new TruthSource());
|
|
|
|
// Model::preventLazyLoading(
|
|
// !$this->app->isProduction()
|
|
// );
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->loadHelpers();
|
|
}
|
|
|
|
protected function loadHelpers()
|
|
{
|
|
foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) {
|
|
require_once $filename;
|
|
}
|
|
}
|
|
}
|