pipicar/modules/UserProfile/Commands/UserProfileInstallCommand.php

67 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
/*
* Copyright (c) 2023.
*
* A.Сапаргалиев
* ТОО "Дизайн лаборатория А7"
* Астана
*/
namespace modules\UserProfile\Commands;
use A7kz\Platform\Commands\InstallCommand;
use A7kz\Platform\Helpers\Facade\Helper;
use A7kz\Platform\Modules\Platform\Acl\Facades\Acl;
use A7kz\Platform\Modules\Platform\Core\Facades\Core;
class UserProfileInstallCommand extends InstallCommand
{
protected $signature = 'user.profile:install {--install} {--upgrade} {--apps}';
protected $description = 'Модуль профиль пользователя';
protected $module_name = 'user.profile';
protected $module_version = '1.0.1';
public function seeds(){
$json = \Storage::disk('a7platform')->get('user/profile.json');
$app = json_decode($json, 1);
$app['class'] = "App.Modules.UserProfile.Applications.UserProfileApplication";
$json = json_encode($app);
Core::registerApp(
"user.profile",
$json,
"Профиль пользователя",
'[]'
);
Acl::addRoleAction("user","user.profile");
Acl::addRoleAction("user","user.profile","edit");
Acl::addRoleAction("user","user.profile","changecompany");
}
public function apps()
{
$this->seeds();
}
public function upgrade()
{
$module = Helper::install()->module($this->module_name);
if(!is_null($module) && !$module->lock_version) {
switch ($module->module_version){
case "1.0.0":
Acl::addRoleAction("user","user.profile","changecompany");
$this->output->writeln($this->description.": v1.0.1");
Helper::install()->installModule($module->module_name,'1.0.1');
Helper::install()->setHistory($module->module_name, $module->module_version,'1.0.1', 'Переключение между организациями');
$module->refresh();
break;
default:
break;
}
}
}
}