snipe-it/app/Providers/EventServiceProvider.php
Wes Hulette 88b1da4260 Added: Caching of settings (#6378)
* Fixed missing oauth tables during setup.

* Cache settings

Cache the setting to reduce unnecessary database calls
2018-11-01 19:59:50 -07:00

59 lines
1.3 KiB
PHP

<?php
namespace App\Providers;
use App\Models\Setting;
use App\Events\SettingSaved;
use App\Listeners\LogListener;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
use App\Listeners\CheckoutableListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'Illuminate\Auth\Events\Login' => [
'App\Listeners\LogSuccessfulLogin',
],
'Illuminate\Auth\Events\Failed' => [
'App\Listeners\LogFailedLogin',
],
];
/**
* The subscriber classes to register.
*
* @var array
*/
protected $subscribe = [
LogListener::class,
CheckoutableListener::class
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
/**
* Clear the LDAP settings cache when the settings model is saved
*/
Event::listen(SettingSaved::class, function () {
Cache::forget(Setting::APP_SETTINGS_KEY);
Cache::forget(Setting::SETUP_CHECK_KEY);
});
}
}