| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\App\Hooks\Handlers; |
| 4 |
|
| 5 |
use FluentBoards\App\Models\Board; |
| 6 |
use FluentBoards\App\Models\Meta; |
| 7 |
use FluentBoards\App\Services\Constant; |
| 8 |
use FluentBoards\Database\DBSeeder; |
| 9 |
use FluentBoards\Database\DBMigrator; |
| 10 |
use FluentBoards\Framework\Foundation\Application; |
| 11 |
|
| 12 |
class ActivationHandler |
| 13 |
{ |
| 14 |
protected $app = null; |
| 15 |
|
| 16 |
public function __construct(Application $app) |
| 17 |
{ |
| 18 |
$this->app = $app; |
| 19 |
} |
| 20 |
|
| 21 |
public function handle($network_wide = false) |
| 22 |
{ |
| 23 |
DBMigrator::run($network_wide); |
| 24 |
DBSeeder::run(); |
| 25 |
|
| 26 |
$this->setOnboarding(); |
| 27 |
} |
| 28 |
|
| 29 |
private function setOnboarding() |
| 30 |
{ |
| 31 |
$isOnboardingSet = Meta::where('key', Constant::FBS_ONBOARDING)->first(); |
| 32 |
if(!$isOnboardingSet){ |
| 33 |
$onboarding = new Meta(); |
| 34 |
$onboarding->object_type = Constant::FBS_ONBOARDING; |
| 35 |
$onboarding->key = Constant::FBS_ONBOARDING; |
| 36 |
$onboarding->value = Board::count() > 0 ? 'yes' : 'no'; |
| 37 |
$onboarding->save(); |
| 38 |
} |
| 39 |
} |
| 40 |
} |