Skip to content

Commit

Permalink
chore: Rename $model field
Browse files Browse the repository at this point in the history
Conflicts with newly added `$model` property which references the Resource’s model
  • Loading branch information
hellopablo committed Aug 6, 2024
1 parent 0de4edf commit c2a40e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Api/Controller/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getRemap($sMethod, array $aData = [])
{
[$sModel, $iItemId] = $this->getModelClassAndId();
$aData['where'] = [
['model', $sModel],
['item_model', $sModel],
['item_id', $iItemId],
];

Expand Down Expand Up @@ -91,7 +91,7 @@ public function postCount(array $aData = [])
foreach ($aIds as $sId) {

$aOut[$sProvider][$sModel][$sId] = $this->oModel->countAll([
new Where('model', $sModelClass),
new Where('item_model', $sModelClass),
new Where('item_id', $sId),
]);
}
Expand Down Expand Up @@ -123,7 +123,7 @@ protected function validateUserInput($aData, $oItem = null): array
$aData = parent::validateUserInput($aData, $oItem);

[$sModel] = $this->getModelClassAndId();
$aData['model'] = $sModel;
$aData['item_model'] = $sModel;

return $aData;
}
Expand Down
27 changes: 27 additions & 0 deletions src/Database/Migration/Migration10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Migration: 10
* Started: 06/08/2024
*
* @package Nails
* @subpackage module-admin
* @category Database Migration
* @author Nails Dev Team
*/

namespace Nails\Admin\Database\Migration;

use Nails\Common\Console\Migrate\Base;

class Migration10 extends Base
{
/**
* Execute the migration
* @return Void
*/
public function execute()
{
$this->query('ALTER TABLE `{{NAILS_DB_PREFIX}}admin_note` CHANGE `model` `item_model` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT \'\';');
}
}
2 changes: 1 addition & 1 deletion src/Resource/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Note extends Entity
{
/** @var string */
public $model;
public $item_model;

/** @var int */
public $item_id;
Expand Down

0 comments on commit c2a40e8

Please sign in to comment.