2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @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\Invoice;
|
|
|
|
use App\Models\Proposal;
|
2021-05-23 23:53:30 +02:00
|
|
|
use App\Utils\Ninja;
|
2022-03-13 10:18:15 +01:00
|
|
|
use App\Utils\TruthSource;
|
2021-02-08 11:11:17 +01:00
|
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
2018-10-22 14:04:37 +02:00
|
|
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
2020-08-11 02:48:05 +02:00
|
|
|
use Illuminate\Queue\Events\JobProcessing;
|
2022-03-14 21:12:37 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2018-10-22 14:04:37 +02:00
|
|
|
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;
|
2022-04-11 09:45:37 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2021-05-23 23:53:30 +02:00
|
|
|
use Livewire\Livewire;
|
2020-03-28 12:34:04 +01:00
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2018-10-22 14:04:37 +02:00
|
|
|
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,
|
2018-10-22 14:04:37 +02:00
|
|
|
]);
|
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
Blade::if('env', function ($environment) {
|
2018-10-22 14:04:37 +02:00
|
|
|
return config('ninja.environment') === $environment;
|
|
|
|
});
|
2019-04-20 00:14:52 +02:00
|
|
|
|
|
|
|
Schema::defaultStringLength(191);
|
|
|
|
|
2021-05-23 23:53:30 +02:00
|
|
|
/* Handles setting the correct database with livewire classes */
|
|
|
|
if(Ninja::isHosted())
|
|
|
|
{
|
|
|
|
Livewire::addPersistentMiddleware([
|
|
|
|
SetDomainNameDb::class,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2022-03-14 21:12:37 +01:00
|
|
|
/* Ensure we don't have stale state in jobs */
|
|
|
|
Queue::before(function (JobProcessing $event) {
|
|
|
|
App::forgetInstance('truthsource');
|
|
|
|
});
|
2022-03-13 10:18:15 +01:00
|
|
|
|
|
|
|
app()->instance(TruthSource::class, new TruthSource());
|
|
|
|
|
2022-04-11 09:45:59 +02:00
|
|
|
// Model::preventLazyLoading(
|
|
|
|
// !$this->app->isProduction()
|
|
|
|
// );
|
2022-04-11 09:45:37 +02:00
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2019-01-22 10:47:26 +01:00
|
|
|
$this->loadHelpers();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function loadHelpers()
|
|
|
|
{
|
|
|
|
foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) {
|
|
|
|
require_once $filename;
|
|
|
|
}
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|
|
|
|
}
|