NotificationFactory::new()->create(); use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Notifications\DatabaseNotification; use Illuminate\Support\Str; class NotificationFactory extends Factory { protected $model = DatabaseNotification::class; public function definition() { return [ 'id' => Str::uuid()->toString(), 'type' => 'App\Notifications\ThreadSubscription', 'notifiable_id' => function() { return auth()->id() ?? User::factory()->create(); }, 'notifiable_type' => 'App\Models\User', 'data' => ['message' => 'text'] ]; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter