From 44df96706aa855fe2571ea6b4cf6c72fe036915f Mon Sep 17 00:00:00 2001 From: Faruk Nasir Date: Thu, 27 Apr 2023 11:03:14 +0100 Subject: [PATCH 1/2] fix: tiny fixes --- config/tithe.php | 5 +++ routes/web.php | 4 +- src/Tithe.php | 42 -------------------- stubs/app/Providers/TitheServiceProvider.php | 7 ++++ 4 files changed, 14 insertions(+), 44 deletions(-) diff --git a/config/tithe.php b/config/tithe.php index 75ef203..7fb75e9 100644 --- a/config/tithe.php +++ b/config/tithe.php @@ -4,6 +4,11 @@ return [ 'ignores_routes' => false, + 'routes' => [ + 'ui' => 'billing', + 'admin' => 'tithe', + ], + 'ignores_migrations' => false, 'favicon' => '', diff --git a/routes/web.php b/routes/web.php index 291f66d..a34a5cf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,7 +5,7 @@ use Tithe\Http\Middleware\Authenticate; use Tithe\Tithe; -Route::middleware(config('tithe.admin_middlewares'))->prefix(Tithe::adminRoutesPrefix())->group(function () { +Route::middleware(config('tithe.admin_middlewares'))->prefix(config('tithe.routes.admin'))->group(function () { // Login routes... Route::get('login', [Controllers\AuthenticatedSessionController::class, 'create'])->name('tithe.login'); Route::post('login', [Controllers\AuthenticatedSessionController::class, 'store'])->name('tithe.authenticate'); @@ -32,7 +32,7 @@ }); }); -Route::middleware(config('tithe.ui_middlewares'))->prefix(Tithe::uiRoutesPrefix())->group(function () { +Route::middleware(config('tithe.ui_middlewares'))->prefix(config('tithe.routes.ui'))->group(function () { Route::get('/', Controllers\BillingController::class)->name('tithe.billing.index'); Route::get('/invoices/{invoiceId}', Controllers\ShowInvoiceController::class)->name('tithe.billing.invoices.show'); Route::get('/create-authorization', Controllers\CreateAuthorizationController::class)->name('tithe.billing.create-authorization'); diff --git a/src/Tithe.php b/src/Tithe.php index 62fa354..1d5406f 100755 --- a/src/Tithe.php +++ b/src/Tithe.php @@ -44,20 +44,6 @@ final class Tithe */ public static $emailsInvoices = true; - /** - * The default admin routes prefix. - * - * @var string - */ - public static $adminRoutesPrefix = 'tithe'; - - /** - * The default ui routes prefix. - * - * @var string - */ - public static $uiRoutesPrefix = 'billing'; - /** * The user model table name. * @@ -261,34 +247,6 @@ public static function emailsInvoices(bool $value = true) return new self(); } - /** - * Sets the default ui routes prefix. - * - * @return static - */ - public static function defaultUiRoutesPrefix(string $prefix) - { - self::$uiRoutesPrefix = $prefix; - - return new self(); - } - - /** - * Returns the default admin routes prefix. - */ - public static function adminRoutesPrefix(): string - { - return self::$adminRoutesPrefix; - } - - /** - * Returns the default ui routes prefix. - */ - public static function uiRoutesPrefix(): string - { - return self::$uiRoutesPrefix; - } - /** * Sets the subscription model's table name. * diff --git a/stubs/app/Providers/TitheServiceProvider.php b/stubs/app/Providers/TitheServiceProvider.php index cd566c0..597cf6d 100644 --- a/stubs/app/Providers/TitheServiceProvider.php +++ b/stubs/app/Providers/TitheServiceProvider.php @@ -33,5 +33,12 @@ public function boot() Tithe::detachFeaturesFromPlansUsing(TitheActions\DetachFeatureFromPlan::class); Tithe::createAuthorizationsUsing(TitheActions\CreateAuthorization::class); Tithe::upgradeSubscriptionsUsing(TitheActions\UpgradeSubscription::class); + Tithe::downgradeSubscriptionsUsing(TitheActions\DowngradeSubscription::class); + Tithe::cancelPendingUpgradesUsing(TitheActions\CancelPendingDowngrade::class); + Tithe::renewSubscriptionsUsing(TitheActions\RenewSubscription::class); + Tithe::getActiveSubscriberUsing(function () { + // edit the following line + return null; + }); } } From c388af597d5a50717c72a49fee0a689459e99f91 Mon Sep 17 00:00:00 2001 From: frknasir Date: Thu, 27 Apr 2023 10:03:53 +0000 Subject: [PATCH 2/2] Fix styling --- routes/web.php | 1 - src/Notifications/SubscriptionRenewalFailed.php | 6 +++--- src/Scopes/ExpiringWithGraceDaysScope.php | 4 ++-- tests/AuthenticatedSessionControllerTest.php | 6 +++--- tests/NewPasswordControllerTest.php | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/routes/web.php b/routes/web.php index a34a5cf..3e885ca 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,7 +3,6 @@ use Illuminate\Support\Facades\Route; use Tithe\Http\Controllers; use Tithe\Http\Middleware\Authenticate; -use Tithe\Tithe; Route::middleware(config('tithe.admin_middlewares'))->prefix(config('tithe.routes.admin'))->group(function () { // Login routes... diff --git a/src/Notifications/SubscriptionRenewalFailed.php b/src/Notifications/SubscriptionRenewalFailed.php index 4362f69..9092e73 100644 --- a/src/Notifications/SubscriptionRenewalFailed.php +++ b/src/Notifications/SubscriptionRenewalFailed.php @@ -37,9 +37,9 @@ public function toMail(object $notifiable): MailMessage $subscriberName = $this->subscriber->titheDisplayName(); return (new MailMessage) - ->greeting('Ooops!') - ->line("We couldn't renew your subscription for {$subscriberName}. Kindly update your payment method.") - ->line('Thank you!'); + ->greeting('Ooops!') + ->line("We couldn't renew your subscription for {$subscriberName}. Kindly update your payment method.") + ->line('Thank you!'); } /** diff --git a/src/Scopes/ExpiringWithGraceDaysScope.php b/src/Scopes/ExpiringWithGraceDaysScope.php index bb8c9c2..c912d10 100644 --- a/src/Scopes/ExpiringWithGraceDaysScope.php +++ b/src/Scopes/ExpiringWithGraceDaysScope.php @@ -18,8 +18,8 @@ public function apply(Builder $builder, Model $model): void { $builder->where( fn (Builder $query) => $query - ->where('expired_at', '>', now()) - ->orWhere('grace_days_ended_at', '>', now()) + ->where('expired_at', '>', now()) + ->orWhere('grace_days_ended_at', '>', now()) ); } diff --git a/tests/AuthenticatedSessionControllerTest.php b/tests/AuthenticatedSessionControllerTest.php index cdf1330..2b61d01 100644 --- a/tests/AuthenticatedSessionControllerTest.php +++ b/tests/AuthenticatedSessionControllerTest.php @@ -10,9 +10,9 @@ test('login page renders', function () { $this->get(route('tithe.login')) - ->assertSuccessful() - ->assertViewIs('tithe::auth.login') - ->assertSeeText('Sign in to your account'); + ->assertSuccessful() + ->assertViewIs('tithe::auth.login') + ->assertSeeText('Sign in to your account'); }); test('login request will check for invalid emails', function () { diff --git a/tests/NewPasswordControllerTest.php b/tests/NewPasswordControllerTest.php index 0909984..69fcc68 100644 --- a/tests/NewPasswordControllerTest.php +++ b/tests/NewPasswordControllerTest.php @@ -13,9 +13,9 @@ $this->get(route('tithe.password.reset', [ 'token' => Str::random(60), ])) - ->assertSuccessful() - ->assertViewIs('tithe::auth.passwords.reset') - ->assertSeeText('Reset Password'); + ->assertSuccessful() + ->assertViewIs('tithe::auth.passwords.reset') + ->assertSeeText('Reset Password'); }); test('tithe user password can be reset', function () {