From b22e3e5459f3b9f05c918a04dc101be8e88ad492 Mon Sep 17 00:00:00 2001 From: MilesChou Date: Fri, 7 Jul 2023 16:07:51 +0800 Subject: [PATCH] Add condition --- app/Console/Commands/OperationActivate.php | 22 +++++++ app/Console/Commands/OperationDeactivate.php | 22 +++++++ app/Console/Commands/OperationStatus.php | 22 +++++++ app/Features/Operation.php | 18 ++++++ app/Providers/FeatureFlagsServiceProvider.php | 2 + .../views/inc/app/navigation-bar.blade.php | 62 ++++++++++--------- resources/views/layouts/app.blade.php | 6 +- resources/views/shop/catalog.blade.php | 22 ++++--- resources/views/shop/show.blade.php | 50 ++++++++------- .../Http/Controllers/User/CatalogPageTest.php | 25 ++++++++ .../Http/Controllers/User/ShopTest.php | 2 + 11 files changed, 187 insertions(+), 66 deletions(-) create mode 100644 app/Console/Commands/OperationActivate.php create mode 100644 app/Console/Commands/OperationDeactivate.php create mode 100644 app/Console/Commands/OperationStatus.php create mode 100644 app/Features/Operation.php diff --git a/app/Console/Commands/OperationActivate.php b/app/Console/Commands/OperationActivate.php new file mode 100644 index 00000000..9d183a5e --- /dev/null +++ b/app/Console/Commands/OperationActivate.php @@ -0,0 +1,22 @@ +activate('operation'); + + $this->line('Activated'); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/OperationDeactivate.php b/app/Console/Commands/OperationDeactivate.php new file mode 100644 index 00000000..3beef04e --- /dev/null +++ b/app/Console/Commands/OperationDeactivate.php @@ -0,0 +1,22 @@ +deactivate('operation'); + + $this->line('Deactivated'); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/OperationStatus.php b/app/Console/Commands/OperationStatus.php new file mode 100644 index 00000000..7e3c1e59 --- /dev/null +++ b/app/Console/Commands/OperationStatus.php @@ -0,0 +1,22 @@ +when('operation', fn() => 'Active', fn() => 'Inactive'); + + $this->line($status); + + return self::SUCCESS; + } +} diff --git a/app/Features/Operation.php b/app/Features/Operation.php new file mode 100644 index 00000000..abe6b85b --- /dev/null +++ b/app/Features/Operation.php @@ -0,0 +1,18 @@ +name = 'operation'; + } + + public function resolve(): bool + { + return true; + } +} diff --git a/app/Providers/FeatureFlagsServiceProvider.php b/app/Providers/FeatureFlagsServiceProvider.php index af7c0acb..4fbae52a 100644 --- a/app/Providers/FeatureFlagsServiceProvider.php +++ b/app/Providers/FeatureFlagsServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Features\Operation; use Illuminate\Support\ServiceProvider; use Laravel\Pennant\Feature; @@ -9,5 +10,6 @@ class FeatureFlagsServiceProvider extends ServiceProvider { public function boot(): void { + Feature::define(Operation::class); } } diff --git a/resources/views/inc/app/navigation-bar.blade.php b/resources/views/inc/app/navigation-bar.blade.php index c0b59bad..ee137fcb 100644 --- a/resources/views/inc/app/navigation-bar.blade.php +++ b/resources/views/inc/app/navigation-bar.blade.php @@ -5,15 +5,17 @@
  • Call us:+4222022
  • + @feature('operation')
  • - Sign up + Sign up
  • - Login + Login
  • - Track my order + Track my order
  • + @endfeature @@ -23,34 +25,36 @@
    -
    - +
    -
    + @csrf -
    +
    -
    - +
    +
    -
    -
    - - @guest - LOGIN - @endguest - @auth - Account - @endauth + @feature('operation') +
    +
    + + @guest + LOGIN + @endguest + @auth + Account + @endauth +
    -
    + @endfeature
    @@ -58,27 +62,27 @@