Skip to content

Commit

Permalink
feat: fix drop foreign key
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Oct 19, 2023
1 parent ecf43fc commit 47af4af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Core/Database/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public function dropColumn(string $name): void
public function dropForeign(string $name): void
{
$this->alter = 'DROP';
$this->query[$this->getLastArray()] = ($this->type == 'mysql' ? 'FOREIGN KEY ' : 'CONSTRAINT ') . $name;
$this->query[$this->getLastArray()] = ($this->type == 'mysql' ? 'FOREIGN KEY' : 'CONSTRAINT') . ' FK_' . $this->table . '_' . $name;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Core/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,17 @@ public function fill(array $fill): Model
/**
* Save perubahan pada attribute dengan primarykey.
*
* @param array $fill
* @return int
*
* @throws Exception
*/
public function save(): int
public function save(array $fill = []): int
{
if ($fill) {
$this->fill($fill);
}

if (empty($this->primaryKey) || empty($this->__get($this->primaryKey))) {
throw new Exception('Nilai primary key tidak ada !');
}
Expand Down

0 comments on commit 47af4af

Please sign in to comment.