Skip to content

Commit

Permalink
#14 #12 신고에 대한 항목 기능 마이그레이션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
xharpenParksuhyeon committed Jun 17, 2022
1 parent e960255 commit aa8e736
Showing 1 changed file with 60 additions and 12 deletions.
72 changes: 60 additions & 12 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,58 @@ public function activate($installedVersion = null)
{
}

/**
* @return void
*/
public function install()
{
$this->createClaimLogTable();
$this->putLang();
$this->setToggleMenuConfig();
}

/**
* @return boolean
*/
public function checkUpdated($installedVersion = NULL)
public function checkUpdated($installedVersion = null)
{
if (version_compare($installedVersion, '0.9.1', '<=')) {
$toggleMenuId = 'module/board@board';
$activated = XeToggleMenu::getActivated($toggleMenuId);
$itemId = 'module/board@board/toggleMenu/claim@boardClaimItem';

if (isset($activated[$itemId]) === false) {
return false;
}

$toggleMenuId = 'comment';
$activated = XeToggleMenu::getActivated($toggleMenuId);
$itemId = 'comment/toggleMenu/claim@commentClaimItem';

if (isset($activated[$itemId]) === false) {
return false;
}
}

if ($this->checkUpdatedClaimLogTable() === false) {
return false;
}

return true;
}

/**
* @param $installedVersion
* @reutrn void
*/
public function update($installedVersion = null)
{
$this->putLang();
$this->setToggleMenuConfig();
}

public function install()
{
$this->createClaimLogTable();
$this->putLang();
$this->setToggleMenuConfig();
if ($this->checkUpdatedClaimLogTable() === false) {
$this->updateClaimLogTable();
}
}

/**
Expand Down Expand Up @@ -127,7 +144,12 @@ protected function setToggleMenuConfig()
}
}

public function createClaimLogTable()
/**
* Create Claim Log Table
*
* @reutrn void
*/
protected function createClaimLogTable()
{
if (Schema::hasTable('claim_logs') === false) {
Schema::create('claim_logs', function (Blueprint $table) {
Expand All @@ -138,16 +160,42 @@ public function createClaimLogTable()
$table->string('user_id', 36);
$table->string('ipaddress', 16);
$table->string('message', 255);
$table->string('category_item_id', 255);
$table->timestamp('created_at');
$table->timestamp('updated_at');
$table->string('category_item_id', 255)->nullable();
$table->timestamps();

$table->index(['target_id', 'user_id']);
$table->index(['target_id', 'claim_type']);
});
}
}

/**
* Update Claim Log Table
*
* @return void
*/
protected function updateClaimLogTable()
{
if (Schema::hasColumn('claim_logs', 'category_item_id') === false) {
Schema::table('site', function (Blueprint $table) {
$table->string('category_item_id', 255)->nullable()->after('message');
});
}
}

/**
* Check Updated Claim Log Table
*
* @return bool
*/
protected function checkUpdatedClaimLogTable()
{
return Schema::hasColumn('claim_logs', 'category_item_id') === true;
}

/**
* @return void
*/
protected function putLang()
{
app('xe.translator')->putFromLangDataSource('claim', base_path('plugins/claim/langs/lang.php'));
Expand Down Expand Up @@ -191,7 +239,7 @@ protected function registerManageRoute()

Route::post('config/update', [
'as' => 'manage.claim.claim.config.update',
'uses' => 'ManagerController@configUpdate'
'uses' => 'ManagerController@updateConfig'
]);

Route::post('config/storeCategory', [
Expand Down

0 comments on commit aa8e736

Please sign in to comment.