From e87029141293520daffa40d40c15c45e48ef0f7b Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Tue, 3 Oct 2023 09:52:30 +0200 Subject: [PATCH] Replace subscriptions plan (#136) * :sparkles: Replace subscriptions package * :white_check_mark: Update tests * Publish laravel stub * Fix code styling * Fix code styling --------- Co-authored-by: mckenziearts --- app/Http/Controllers/HomeController.php | 2 +- app/Models/{Premium => }/Plan.php | 9 +- app/Models/Premium/Feature.php | 17 - app/Models/Premium/Subscription.php | 17 - app/Models/Premium/SubscriptionUsage.php | 17 - composer.json | 1 + composer.lock | 301 +++++++++++++++++- config/laravel-subscriptions.php | 44 +++ config/rinvex.subscriptions.php | 30 -- .../2023_10_03_064550_create_plans_table.php | 47 +++ ...0_03_064551_create_plan_features_table.php | 34 ++ ...64552_create_plan_subscriptions_table.php} | 28 +- ...3_create_plan_subscription_usage_table.php | 32 ++ .../2022_10_15_183646_create_plans_table.php | 46 --- ...0_15_183647_create_plan_features_table.php | 37 --- ...9_create_plan_subscription_usage_table.php | 34 -- .../seeders/DeveloperPremiumPlanSeeder.php | 36 +-- helpers/ModelHelper.php | 7 +- stubs/cast.stub | 31 ++ stubs/console.stub | 19 ++ stubs/controller.invokable.stub | 15 + stubs/controller.plain.stub | 13 + stubs/event.stub | 35 ++ stubs/factory.stub | 19 ++ stubs/job.queued.stub | 27 ++ stubs/mail.stub | 41 +++ stubs/markdown-mail.stub | 41 +++ stubs/markdown-notification.stub | 50 +++ stubs/middleware.stub | 17 + stubs/migration.create.stub | 26 ++ stubs/migration.stub | 20 ++ stubs/migration.update.stub | 24 ++ stubs/model.pivot.stub | 12 + stubs/model.stub | 17 + stubs/notification.stub | 40 +++ stubs/observer.plain.stub | 10 + stubs/policy.stub | 47 +++ stubs/provider.stub | 20 ++ stubs/request.stub | 27 ++ stubs/resource-collection.stub | 21 ++ stubs/resource.stub | 21 ++ stubs/rule.stub | 19 ++ stubs/scope.stub | 17 + stubs/seeder.stub | 16 + stubs/view-component.stub | 22 ++ tests/Feature/UserActivitiesTest.php | 5 - tests/Integration/ChannelTest.php | 2 +- tests/Pest.php | 39 +-- tests/Unit/ExampleTest.php | 7 - 49 files changed, 1166 insertions(+), 293 deletions(-) rename app/Models/{Premium => }/Plan.php (69%) delete mode 100644 app/Models/Premium/Feature.php delete mode 100644 app/Models/Premium/Subscription.php delete mode 100644 app/Models/Premium/SubscriptionUsage.php create mode 100644 config/laravel-subscriptions.php delete mode 100644 config/rinvex.subscriptions.php create mode 100644 database/migrations/2023_10_03_064550_create_plans_table.php create mode 100644 database/migrations/2023_10_03_064551_create_plan_features_table.php rename database/migrations/{rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php => 2023_10_03_064552_create_plan_subscriptions_table.php} (54%) create mode 100644 database/migrations/2023_10_03_064553_create_plan_subscription_usage_table.php delete mode 100644 database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php delete mode 100644 database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php delete mode 100644 database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php create mode 100644 stubs/cast.stub create mode 100644 stubs/console.stub create mode 100644 stubs/controller.invokable.stub create mode 100644 stubs/controller.plain.stub create mode 100644 stubs/event.stub create mode 100644 stubs/factory.stub create mode 100644 stubs/job.queued.stub create mode 100644 stubs/mail.stub create mode 100644 stubs/markdown-mail.stub create mode 100644 stubs/markdown-notification.stub create mode 100644 stubs/middleware.stub create mode 100644 stubs/migration.create.stub create mode 100644 stubs/migration.stub create mode 100644 stubs/migration.update.stub create mode 100644 stubs/model.pivot.stub create mode 100644 stubs/model.stub create mode 100644 stubs/notification.stub create mode 100644 stubs/observer.plain.stub create mode 100644 stubs/policy.stub create mode 100644 stubs/provider.stub create mode 100644 stubs/request.stub create mode 100644 stubs/resource-collection.stub create mode 100644 stubs/resource.stub create mode 100644 stubs/rule.stub create mode 100644 stubs/scope.stub create mode 100644 stubs/seeder.stub create mode 100644 stubs/view-component.stub delete mode 100644 tests/Unit/ExampleTest.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index ecddc4fa..4a833da7 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -6,7 +6,7 @@ use App\Models\Article; use App\Models\Discussion; -use App\Models\Premium\Plan; +use App\Models\Plan; use App\Models\Thread; use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Cache; diff --git a/app/Models/Premium/Plan.php b/app/Models/Plan.php similarity index 69% rename from app/Models/Premium/Plan.php rename to app/Models/Plan.php index 1f5520dc..6a315e57 100644 --- a/app/Models/Premium/Plan.php +++ b/app/Models/Plan.php @@ -2,21 +2,18 @@ declare(strict_types=1); -namespace App\Models\Premium; +namespace App\Models; use App\Enums\PlanType; +use App\Models\Premium\IdeHelperPlan; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Factories\HasFactory; -// use Rinvex\Subscriptions\Models\Plan as Model; -use Illuminate\Database\Eloquent\Model; +use Laravelcm\Subscriptions\Models\Plan as Model; /** * @mixin IdeHelperPlan */ final class Plan extends Model { - use HasFactory; - public function scopeDeveloper(Builder $query): Builder { return $query->where('type', PlanType::DEVELOPER->value); diff --git a/app/Models/Premium/Feature.php b/app/Models/Premium/Feature.php deleted file mode 100644 index 9e370367..00000000 --- a/app/Models/Premium/Feature.php +++ /dev/null @@ -1,17 +0,0 @@ - [ + 'plans' => 'plans', + 'features' => 'plan_features', + 'subscriptions' => 'plan_subscriptions', + 'subscription_usage' => 'plan_subscription_usage', + ], + + /* + |-------------------------------------------------------------------------- + | Subscription Models + |-------------------------------------------------------------------------- + | + | Models used to manage subscriptions. You can replace to use your own models, + | but make sure that you have the same functionalities or that your models + | extend from each model that you are going to replace. + | + */ + + 'models' => [ + 'plan' => App\Models\Plan::class, + 'feature' => Feature::class, + 'subscription' => Subscription::class, + 'subscription_usage' => SubscriptionUsage::class, + ], + +]; diff --git a/config/rinvex.subscriptions.php b/config/rinvex.subscriptions.php deleted file mode 100644 index ab72bf00..00000000 --- a/config/rinvex.subscriptions.php +++ /dev/null @@ -1,30 +0,0 @@ - false, - - // Subscriptions Database Tables - 'tables' => [ - - 'plans' => 'plans', - 'plan_features' => 'plan_features', - 'plan_subscriptions' => 'plan_subscriptions', - 'plan_subscription_usage' => 'plan_subscription_usage', - - ], - - // Subscriptions Models - 'models' => [ - - 'plan' => \App\Models\Premium\Plan::class, - 'plan_feature' => \App\Models\Premium\Feature::class, - 'plan_subscription' => \App\Models\Premium\Subscription::class, - 'plan_subscription_usage' => \App\Models\Premium\SubscriptionUsage::class, - - ], - -]; diff --git a/database/migrations/2023_10_03_064550_create_plans_table.php b/database/migrations/2023_10_03_064550_create_plans_table.php new file mode 100644 index 00000000..591038ca --- /dev/null +++ b/database/migrations/2023_10_03_064550_create_plans_table.php @@ -0,0 +1,47 @@ +id(); + + $table->json('name'); + $table->string('slug')->unique(); + $table->string('type')->default(PlanType::DEVELOPER->value); + $table->json('description')->nullable(); + $table->boolean('is_active')->default(true); + $table->decimal('price')->default('0.00'); + $table->decimal('signup_fee')->default('0.00'); + $table->string('currency', 3); + $table->unsignedSmallInteger('trial_period')->default(0); + $table->string('trial_interval')->default(Interval::DAY->value); + $table->unsignedSmallInteger('invoice_period')->default(0); + $table->string('invoice_interval')->default(Interval::MONTH->value); + $table->unsignedSmallInteger('grace_period')->default(0); + $table->string('grace_interval')->default(Interval::DAY->value); + $table->unsignedTinyInteger('prorate_day')->nullable(); + $table->unsignedTinyInteger('prorate_period')->nullable(); + $table->unsignedTinyInteger('prorate_extend_due')->nullable(); + $table->unsignedSmallInteger('active_subscribers_limit')->nullable(); + $table->unsignedSmallInteger('sort_order')->default(0); + + $table->timestamps(); + $table->softDeletes(); + }); + } + + + public function down(): void + { + Schema::dropIfExists(config('laravel-subscriptions.tables.plans')); + } +}; diff --git a/database/migrations/2023_10_03_064551_create_plan_features_table.php b/database/migrations/2023_10_03_064551_create_plan_features_table.php new file mode 100644 index 00000000..739c72b2 --- /dev/null +++ b/database/migrations/2023_10_03_064551_create_plan_features_table.php @@ -0,0 +1,34 @@ +id(); + + $table->foreignIdFor(Plan::class); + $table->json('name'); + $table->string('slug')->unique(); + $table->json('description')->nullable(); + $table->string('value'); + $table->unsignedSmallInteger('resettable_period')->default(0); + $table->string('resettable_interval')->default('month'); + $table->unsignedMediumInteger('sort_order')->default(0); + + $table->timestamps(); + $table->softDeletes(); + }); + } + + public function down(): void + { + Schema::dropIfExists(config('laravel-subscriptions.tables.features')); + } +}; diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php b/database/migrations/2023_10_03_064552_create_plan_subscriptions_table.php similarity index 54% rename from database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php rename to database/migrations/2023_10_03_064552_create_plan_subscriptions_table.php index 96bf87f7..c15fae9b 100644 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php +++ b/database/migrations/2023_10_03_064552_create_plan_subscriptions_table.php @@ -2,38 +2,36 @@ declare(strict_types=1); -use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; +use Illuminate\Support\Facades\Schema; +use Laravelcm\Subscriptions\Models\Plan; -final class CreatePlanSubscriptionsTable extends Migration -{ +return new class () extends Migration { public function up(): void { - Schema::create(config('rinvex.subscriptions.tables.plan_subscriptions'), function (Blueprint $table): void { - $table->increments('id'); + Schema::create(config('laravel-subscriptions.tables.subscriptions'), function (Blueprint $table): void { + $table->id(); + $table->morphs('subscriber'); - $table->integer('plan_id')->unsigned(); - $table->string('slug'); + $table->foreignIdFor(Plan::class); $table->json('name'); + $table->string('slug')->unique(); $table->json('description')->nullable(); + $table->string('timezone')->nullable(); + $table->dateTime('trial_ends_at')->nullable(); $table->dateTime('starts_at')->nullable(); $table->dateTime('ends_at')->nullable(); $table->dateTime('cancels_at')->nullable(); $table->dateTime('canceled_at')->nullable(); - $table->string('timezone')->nullable(); $table->timestamps(); $table->softDeletes(); - - // Indexes - $table->unique('slug'); - $table->foreign('plan_id')->references('id')->on(config('rinvex.subscriptions.tables.plans')) - ->onDelete('cascade')->onUpdate('cascade'); }); } public function down(): void { - Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscriptions')); + Schema::dropIfExists(config('laravel-subscriptions.tables.subscriptions')); } -} +}; diff --git a/database/migrations/2023_10_03_064553_create_plan_subscription_usage_table.php b/database/migrations/2023_10_03_064553_create_plan_subscription_usage_table.php new file mode 100644 index 00000000..389c976e --- /dev/null +++ b/database/migrations/2023_10_03_064553_create_plan_subscription_usage_table.php @@ -0,0 +1,32 @@ +id(); + + $table->foreignIdFor(Subscription::class); + $table->foreignIdFor(Feature::class); + $table->unsignedSmallInteger('used'); + $table->string('timezone')->nullable(); + + $table->dateTime('valid_until')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + public function down(): void + { + Schema::dropIfExists(config('laravel-subscriptions.tables.subscription_usage')); + } +}; diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php deleted file mode 100644 index 04ee1d24..00000000 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php +++ /dev/null @@ -1,46 +0,0 @@ -increments('id'); - $table->string('slug'); - $table->json('name'); - $table->string('type')->default(\App\Enums\PlanType::DEVELOPER->value); - $table->json('description')->nullable(); - $table->boolean('is_active')->default(true); - $table->decimal('price')->default('0.00'); - $table->decimal('signup_fee')->default('0.00'); - $table->string('currency', 3); - $table->smallInteger('trial_period')->unsigned()->default(0); - $table->string('trial_interval')->default('day'); - $table->smallInteger('invoice_period')->unsigned()->default(0); - $table->string('invoice_interval')->default('month'); - $table->smallInteger('grace_period')->unsigned()->default(0); - $table->string('grace_interval')->default('day'); - $table->tinyInteger('prorate_day')->unsigned()->nullable(); - $table->tinyInteger('prorate_period')->unsigned()->nullable(); - $table->tinyInteger('prorate_extend_due')->unsigned()->nullable(); - $table->smallInteger('active_subscribers_limit')->unsigned()->nullable(); - $table->mediumInteger('sort_order')->unsigned()->default(0); - $table->timestamps(); - $table->softDeletes(); - - // Indexes - $table->unique('slug'); - }); - } - - public function down(): void - { - Schema::dropIfExists(config('rinvex.subscriptions.tables.plans')); - } -} diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php deleted file mode 100644 index 6892eab5..00000000 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php +++ /dev/null @@ -1,37 +0,0 @@ -increments('id'); - $table->integer('plan_id')->unsigned(); - $table->string('slug'); - $table->json('name'); - $table->json('description')->nullable(); - $table->string('value'); - $table->smallInteger('resettable_period')->unsigned()->default(0); - $table->string('resettable_interval')->default('month'); - $table->mediumInteger('sort_order')->unsigned()->default(0); - $table->timestamps(); - $table->softDeletes(); - - // Indexes - $table->unique(['plan_id', 'slug']); - $table->foreign('plan_id')->references('id')->on(config('rinvex.subscriptions.tables.plans')) - ->onDelete('cascade')->onUpdate('cascade'); - }); - } - - public function down(): void - { - Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_features')); - } -} diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php deleted file mode 100644 index 7b474098..00000000 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php +++ /dev/null @@ -1,34 +0,0 @@ -increments('id'); - $table->integer('subscription_id')->unsigned(); - $table->integer('feature_id')->unsigned(); - $table->smallInteger('used')->unsigned(); - $table->dateTime('valid_until')->nullable(); - $table->string('timezone')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['subscription_id', 'feature_id']); - $table->foreign('subscription_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_subscriptions')) - ->onDelete('cascade')->onUpdate('cascade'); - $table->foreign('feature_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_features')) - ->onDelete('cascade')->onUpdate('cascade'); - }); - } - - public function down(): void - { - Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscription_usage')); - } -} diff --git a/database/seeders/DeveloperPremiumPlanSeeder.php b/database/seeders/DeveloperPremiumPlanSeeder.php index b71ac22a..957cbb30 100644 --- a/database/seeders/DeveloperPremiumPlanSeeder.php +++ b/database/seeders/DeveloperPremiumPlanSeeder.php @@ -5,9 +5,10 @@ namespace Database\Seeders; use App\Enums\PlanType; -use App\Models\Premium\Feature; -use App\Models\Premium\Plan; +use App\Models\Plan; use Illuminate\Database\Seeder; +use Laravelcm\Subscriptions\Interval; +use Laravelcm\Subscriptions\Models\Feature; final class DeveloperPremiumPlanSeeder extends Seeder { @@ -15,49 +16,46 @@ public function run(): void { $rookiePlan = Plan::create([ 'name' => 'Le Rookie', - 'description' => 'Le Rookie plan', + 'description' => 'Pour tous ceux qui veulent apprendre et avoir le contenu minimal', 'type' => PlanType::DEVELOPER->value, 'price' => 2000, 'signup_fee' => 0, 'invoice_period' => 1, - 'invoice_interval' => 'month', - 'trial_period' => 0, - 'trial_interval' => 'day', + 'invoice_interval' => Interval::MONTH->value, + 'trial_period' => 7, + 'trial_interval' => Interval::DAY->value, 'sort_order' => 1, 'currency' => 'XAF', ]); $rookiePlan->features()->saveMany([ - new Feature(['name' => 'Voir les vidéos premium', 'value' => 1, 'sort_order' => 1]), - new Feature(['name' => 'Écouter les Podcasts premium', 'value' => 1, 'sort_order' => 2]), - new Feature(['name' => 'Poster des tutoriels vidéo', 'value' => 1, 'sort_order' => 3]), + new Feature(['name' => 'Voir les vidéos Premium', 'value' => 1, 'sort_order' => 1]), + new Feature(['name' => 'Écouter les Podcasts Premium', 'value' => 1, 'sort_order' => 2]), new Feature(['name' => 'Badge Premium sur le profil', 'value' => 1, 'sort_order' => 4]), new Feature(['name' => 'Accès au code source des tutoriels', 'value' => 1, 'sort_order' => 5]), - new Feature(['name' => 'Invitation sur le Github du projet', 'value' => 1, 'sort_order' => 6]), ]); $proPlan = Plan::create([ 'name' => 'Le Pro', - 'description' => 'Le Pro plan', + 'description' => 'Pour les professionnels du métier', 'type' => PlanType::DEVELOPER->value, 'price' => 5000, 'signup_fee' => 0, 'invoice_period' => 1, - 'invoice_interval' => 'month', - 'trial_period' => 0, - 'trial_interval' => 'day', + 'invoice_interval' => Interval::MONTH->value, + 'trial_period' => 7, + 'trial_interval' => Interval::DAY->value, 'sort_order' => 1, 'currency' => 'XAF', ]); $proPlan->features()->saveMany([ new Feature(['name' => 'Voir les vidéos premium', 'value' => 1, 'sort_order' => 1]), new Feature(['name' => 'Écouter les Podcasts premium', 'value' => 1, 'sort_order' => 2]), - new Feature(['name' => 'Poster des tutoriels vidéo', 'value' => 1, 'sort_order' => 3]), - new Feature(['name' => 'Badge Premium sur le profil', 'value' => 1, 'sort_order' => 4]), + new Feature(['name' => 'Badge Premium sur le profil', 'value' => 1, 'sort_order' => 3]), + new Feature(['name' => 'Invitation channel privé sur Discord', 'value' => 1, 'sort_order' => 4]), new Feature(['name' => 'Accès au code source des tutoriels', 'value' => 1, 'sort_order' => 5]), - new Feature(['name' => 'Invitation sur le Github du projet', 'value' => 1, 'sort_order' => 6]), - new Feature(['name' => 'Invitation channel privé sur Discord', 'value' => 1, 'sort_order' => 7]), - new Feature(['name' => 'E-Books Laravel, Design UI/UX, etc', 'value' => 1, 'sort_order' => 8]), + new Feature(['name' => 'E-Books Laravel, Design UI/UX, etc', 'value' => 1, 'sort_order' => 6]), new Feature(['name' => '2 heures (2 séances) de consultation mensuelle gratuite', 'value' => 1, 'sort_order' => 9]), + new Feature(['name' => 'Logo sur la page des articles', 'value' => 1, 'sort_order' => 8]), ]); } } diff --git a/helpers/ModelHelper.php b/helpers/ModelHelper.php index 3a47d4c1..dfa15fdc 100644 --- a/helpers/ModelHelper.php +++ b/helpers/ModelHelper.php @@ -315,7 +315,7 @@ final class IdeHelperFeature * @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $deleted_at * @property-read array $translations - * @property-read \App\Models\Premium\Plan $plan + * @property-read \App\Models\Plan $plan * @property-read \Illuminate\Database\Eloquent\Collection $usage * @property-read int|null $usage_count * @method static \Illuminate\Database\Eloquent\Builder|PlanFeature byPlanId(int $planId) @@ -345,7 +345,8 @@ final class IdeHelperFeature } } -namespace App\Models\Premium{ +namespace App\Models\Premium{use App\Models\Plan; + /** * App\Models\Premium\Plan * @@ -437,7 +438,7 @@ final class IdeHelperPlan * @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $deleted_at * @property-read array $translations - * @property-read \App\Models\Premium\Plan $plan + * @property-read \App\Models\Plan $plan * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $subscriber * @property-read \Illuminate\Database\Eloquent\Collection $usage * @property-read int|null $usage_count diff --git a/stubs/cast.stub b/stubs/cast.stub new file mode 100644 index 00000000..2a911410 --- /dev/null +++ b/stubs/cast.stub @@ -0,0 +1,31 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/stubs/console.stub b/stubs/console.stub new file mode 100644 index 00000000..ccc30e55 --- /dev/null +++ b/stubs/console.stub @@ -0,0 +1,19 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('channel-name'), + ]; + } +} diff --git a/stubs/factory.stub b/stubs/factory.stub new file mode 100644 index 00000000..b5d39f58 --- /dev/null +++ b/stubs/factory.stub @@ -0,0 +1,19 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage)->markdown('{{ view }}'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/stubs/middleware.stub b/stubs/middleware.stub new file mode 100644 index 00000000..76b7b537 --- /dev/null +++ b/stubs/middleware.stub @@ -0,0 +1,17 @@ +id(); + + // + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('{{ table }}'); + } +}; diff --git a/stubs/migration.stub b/stubs/migration.stub new file mode 100644 index 00000000..62a5c4a8 --- /dev/null +++ b/stubs/migration.stub @@ -0,0 +1,20 @@ +line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/stubs/observer.plain.stub b/stubs/observer.plain.stub new file mode 100644 index 00000000..61270dde --- /dev/null +++ b/stubs/observer.plain.stub @@ -0,0 +1,10 @@ + + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/stubs/resource-collection.stub b/stubs/resource-collection.stub new file mode 100644 index 00000000..68149ea7 --- /dev/null +++ b/stubs/resource-collection.stub @@ -0,0 +1,21 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/stubs/resource.stub b/stubs/resource.stub new file mode 100644 index 00000000..694cb82e --- /dev/null +++ b/stubs/resource.stub @@ -0,0 +1,21 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/stubs/rule.stub b/stubs/rule.stub new file mode 100644 index 00000000..10282733 --- /dev/null +++ b/stubs/rule.stub @@ -0,0 +1,19 @@ +createUser(); diff --git a/tests/Integration/ChannelTest.php b/tests/Integration/ChannelTest.php index aa1de874..a9a610e0 100644 --- a/tests/Integration/ChannelTest.php +++ b/tests/Integration/ChannelTest.php @@ -5,7 +5,7 @@ use App\Exceptions\CannotAddChannelToChild; use App\Models\Channel; -test('channel can have childs', function (): void { +test('channel can have children', function (): void { $channel = Channel::factory()->create(); Channel::factory()->count(2)->create(['parent_id' => $channel->id]); diff --git a/tests/Pest.php b/tests/Pest.php index 2e578686..f6a24083 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -2,42 +2,7 @@ declare(strict_types=1); -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\RefreshDatabase; -/* -|-------------------------------------------------------------------------- -| Test Case -|-------------------------------------------------------------------------- -| -| The closure you provide to your test functions is always bound to a specific PHPUnit test -| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may -| need to change it using the "uses()" function to bind a different classes or traits. -| -*/ - -uses(Tests\TestCase::class, RefreshDatabase::class, DatabaseMigrations::class)->in('Feature', 'Integration', 'Unit'); - -/* -|-------------------------------------------------------------------------- -| Expectations -|-------------------------------------------------------------------------- -| -| When you're writing tests, you often need to check that values meet certain conditions. The -| "expect()" function gives you access to a set of "expectations" methods that you can use -| to assert different things. Of course, you may extend the Expectation API at any time. -| -*/ - -/** @link https://pestphp.com/docs/expectations#custom-expectations */ - -/* -|-------------------------------------------------------------------------- -| Functions -|-------------------------------------------------------------------------- -| -| While Pest is very powerful out-of-the-box, you may have some testing code specific to your -| project that you don't want to repeat in every file. Here you can also expose helpers as -| global functions to help you to reduce the number of lines of code in your test files. -| -*/ +uses(Tests\TestCase::class, RefreshDatabase::class) + ->in('Feature', 'Integration'); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 17e2d602..00000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,7 +0,0 @@ -assertTrue(true); -});