generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for disabling trait specific handlers
- Loading branch information
Kurt Friars
committed
Jan 31, 2025
1 parent
60030a9
commit 475d3c5
Showing
7 changed files
with
139 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Plank\LaravelHush\Tests\Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Plank\LaravelHush\Tests\Models\Post; | ||
|
||
/** | ||
* @extends Factory<Post> | ||
*/ | ||
class PostFactory extends Factory | ||
{ | ||
protected $model = Post::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function definition(): array | ||
{ | ||
return [ | ||
'title' => $this->faker->title, | ||
'body' => $this->faker->paragraphs(3, true), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('posts', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('title'); | ||
$table->text('body'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Plank\LaravelHush\Tests\Models\Concerns; | ||
|
||
trait HasEventHandlersInTrait | ||
{ | ||
public static function bootHasEventHandlersInTrait(): void | ||
{ | ||
static::deleting(function () { | ||
throw new \Exception('deleting in trait'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Plank\LaravelHush\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Plank\LaravelHush\Concerns\HushesHandlers; | ||
use Plank\LaravelHush\Tests\Database\Factories\PostFactory; | ||
use Plank\LaravelHush\Tests\Models\Concerns\HasEventHandlersInTrait; | ||
|
||
class Post extends Model | ||
{ | ||
use HasEventHandlersInTrait; | ||
use HasFactory; | ||
use HushesHandlers; | ||
|
||
protected $guarded = []; | ||
|
||
/** | ||
* Create a new factory instance for the model. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Factories\Factory<static> | ||
*/ | ||
protected static function newFactory() | ||
{ | ||
return PostFactory::new(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters