Skip to content

Commit

Permalink
if no extension
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Jun 19, 2024
1 parent 231cb4c commit 9b7d0ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Models/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public function getTable(): string
protected static function booted(): void
{
static::deleting(function (Form $form) {
$canDelete = (bool) Extensions::init($form, 'canDelete', []);
$canDelete = Extensions::init($form, 'canDelete', []);

if ($canDelete === null) {
$canDelete = true;
}

if (! $canDelete) {
Notification::make()
->title(__('Can\'t delete a form linked to an Extensions'))
Expand Down
7 changes: 6 additions & 1 deletion src/Models/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public function getTable()
protected static function booted(): void
{
static::deleting(function (Response $response) {
$canDelete = (bool) Extensions::init($response->form, 'canDeleteResponse', ['response' => $response]);
$canDelete = Extensions::init($response->form, 'canDeleteResponse', ['response' => $response]);

if ($canDelete === null) {
$canDelete = true;
}

if (! $canDelete) {
Notification::make()
->title(__('Can\'t delete a form linked to an Extensions'))
Expand Down

0 comments on commit 9b7d0ed

Please sign in to comment.