Hi. I've got a SettingsServiceProvider class that gets the site settings from the database and caches it so the config item can be used all through the app. The issue im getting is once i deploy to the test server the code executes before it gets a chance to migrate the settings table and so it fails. This is using Laravel Forge to deploy. Is there a way to call the service only if the table exists?
Heres the service provider.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Cache\Factory;
use App\Models\AppSetting;
class SettingServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(Factory $cache, AppSetting $settings = null)
{
$settings = $cache->remember('settings', 60, function() use ($settings){
return $settings->pluck('value', 'name')->all();
});
config()->set('settings', $settings);
}
}