Working proposal apply code, fixed schema (need reset - artisan migrate:fresh)

This commit is contained in:
2018-08-11 18:42:12 +02:00
parent 8efc31d820
commit f2910f977f
12 changed files with 168 additions and 69 deletions
+9 -5
View File
@@ -136,16 +136,17 @@ class Changeset
* Note that the fromProposal() method should be used when the
* proposal is available, as it populates additional fields.
*
* @param \stdClass $changes
* @param \stdClass $object
* @return Changeset
*/
public static function fromObject($changes)
public static function fromObject($object)
{
$object = (array)$object;
$changeset = new Changeset();
foreach ($changeset->walkProps() as $prop) {
if (isset($changes->$prop)) {
$changeset->$prop = $changes->$prop;
if (isset($object[$prop])) {
$changeset->$prop = $object[$prop];
}
}
@@ -212,7 +213,7 @@ class Changeset
}
// if marked for removal, hide changes
if (!$row->_remove) {
if (!isset($row->_remove) || !$row->_remove) {
// Changed values
if (isset($this->rowUpdates[$row->_id])) {
$newVals = $this->rowUpdates[$row->_id];
@@ -233,6 +234,7 @@ class Changeset
}
}
// move junk left over from the select
unset($row->_row_pivot);
if ($decorate) {
@@ -857,6 +859,8 @@ class Changeset
*/
public function renumberRows()
{
if (count($this->newRows) == 0) return;
$rows = [];
$numerator = new RowNumerator(count($this->newRows));
foreach ($this->newRows as $row) {
+20 -11
View File
@@ -154,18 +154,27 @@ class Column implements JsonSerializable, Arrayable
/**
* @return array with keys {name, title, type}
*/
public function toArray()
public function toArray($decorate=true)
{
return [
'id' => $this->id,
'name' => $this->name,
'title' => $this->title,
'type' => $this->type,
'_new' => $this->isNew,
'_remove' => $this->toRemove,
'_changed' => $this->modified_attribs,
'_orig' => $this->orig_attribs,
];
if ($decorate) {
return [
'id' => $this->id,
'name' => $this->name,
'title' => $this->title,
'type' => $this->type,
'_new' => $this->isNew,
'_remove' => $this->toRemove,
'_changed' => $this->modified_attribs,
'_orig' => $this->orig_attribs,
];
} else {
return [
'id' => $this->id,
'name' => $this->name,
'title' => $this->title,
'type' => $this->type,
];
}
}
/**