Skip to content

Commit

Permalink
add cascade on delete product
Browse files Browse the repository at this point in the history
  • Loading branch information
wouerner committed Feb 29, 2024
1 parent 294d5e6 commit 71f8894
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ public function update(RequestInterface $request, $id)
$linkedin = $this->request->input('linkedin');
$password = $this->request->input('password');


$user->name = $name;
$user->email = $email;
$user->password = password_hash($password, PASSWORD_BCRYPT); // Hash da senha
$user->linkedin = $linkedin;

if ($password) {
$user->password = password_hash($password, PASSWORD_BCRYPT);
}

$user->save();

return $this->response->json([
Expand Down
2 changes: 1 addition & 1 deletion migrations/2024_01_27_110523_create_squads_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function up(): void

$table->index('uuid');

$table->foreign('product_uuid')->references('uuid')->on('products')->onDelete('set null');
$table->foreign('product_uuid')->references('uuid')->on('products')->onDelete('cascade');
});
}

Expand Down

0 comments on commit 71f8894

Please sign in to comment.