Skip to content

Commit 96ccae1

Browse files
authored
Merge pull request #13 from yabhq/feat/soft-deletes-on-by-default
Default soft deletes to on by default for new models and migrations
2 parents 2d742dd + 74d7230 commit 96ccae1

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

src/Stubs/migration.create.stub

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class {{ class }} extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('{{ table }}', function (Blueprint $table) {
17+
$table->id();
18+
$table->timestamps();
19+
$table->softDeletes();
20+
});
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*
26+
* @return void
27+
*/
28+
public function down()
29+
{
30+
Schema::dropIfExists('{{ table }}');
31+
}
32+
}

src/Stubs/model.stub

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace {{ namespace }};
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use Illuminate\Database\Eloquent\Factories\HasFactory;
8+
9+
class {{ class }} extends Model
10+
{
11+
use HasFactory, SoftDeletes;
12+
}

src/Stubs/test.stub

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ class {{ class }} extends TestCase
1313
/** @test */
1414
public function test_example()
1515
{
16-
$response = $this->post(route('api.test.example'), []);
16+
$response = $this->post(route('api.example'), []);
1717

1818
// $response->assertOk();
19+
20+
// $response->assertJson([
21+
//
22+
// ]);
23+
24+
// $response->assertJsonStructure([
25+
// 'errors' => [
26+
//
27+
// ],
28+
// ]);
1929
}
2030
}

src/Stubs/test.unit.stub

+4
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ class {{ class }} extends TestCase
1313
public function test_example()
1414
{
1515
$this->assertTrue(true);
16+
17+
// $this->assertDatabaseHas('example', [
18+
//
19+
// ]);
1620
}
1721
}

0 commit comments

Comments
 (0)