Snippets Collections
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']
        ];
    }
}
star

Sat Jan 20 2024 02:12:05 GMT+0000 (Coordinated Universal Time) https://github.com/LaravelDaily/laravel-tips/blob/master/factories.md

#laravel #factory #factories
star

Wed Mar 24 2021 17:00:56 GMT+0000 (Coordinated Universal Time)

#laravel #factory

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension