From 0eadab49f16f047bb99d72a951836f4a9d8a1e28 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 29 Oct 2024 15:26:18 -0700 Subject: [PATCH] Add soft deletes --- app/Models/ReportTemplate.php | 2 ++ .../2023_08_23_232739_create_report_templates_table.php | 1 + tests/Feature/ReportTemplates/DeleteReportTemplateTest.php | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Models/ReportTemplate.php b/app/Models/ReportTemplate.php index 5c371a82df..9827252419 100644 --- a/app/Models/ReportTemplate.php +++ b/app/Models/ReportTemplate.php @@ -6,11 +6,13 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\SoftDeletes; use Watson\Validating\ValidatingTrait; class ReportTemplate extends Model { use HasFactory; + use SoftDeletes; use ValidatingTrait; protected $casts = [ diff --git a/database/migrations/2023_08_23_232739_create_report_templates_table.php b/database/migrations/2023_08_23_232739_create_report_templates_table.php index 0ca44f0070..d9438f2cc8 100644 --- a/database/migrations/2023_08_23_232739_create_report_templates_table.php +++ b/database/migrations/2023_08_23_232739_create_report_templates_table.php @@ -18,6 +18,7 @@ class CreateReportTemplatesTable extends Migration $table->integer('created_by')->nullable(); $table->string('name'); $table->json('options'); + $table->softDeletes(); $table->timestamps(); $table->index('created_by'); }); diff --git a/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php b/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php index 5698f6f0a5..7d9067ff07 100644 --- a/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php +++ b/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php @@ -43,7 +43,7 @@ class DeleteReportTemplateTest extends TestCase implements TestsPermissionsRequi ->delete($this->getRoute($reportTemplate)) ->assertRedirect(route('reports/custom')); - $this->assertModelMissing($reportTemplate); + $this->assertSoftDeleted($reportTemplate); } private function getRoute(ReportTemplate $reportTemplate): string