From b081d90cc7e5c737daf9c5bbf553fbba3a4fa238 Mon Sep 17 00:00:00 2001 From: Dedan Irungu Date: Tue, 15 Aug 2023 21:01:36 +0300 Subject: [PATCH] adding option to enum for system display formkit --- Entities/BillingCycle.php | 6 ++++-- Entities/MacAddress.php | 2 +- Entities/Package.php | 11 +++++++---- Entities/PackageCharge.php | 4 ++-- Entities/PackageChargeRate.php | 4 ++-- Entities/Payment.php | 4 ++-- Entities/PaymentCharge.php | 4 ++-- Entities/PaymentChargeRate.php | 4 ++-- Entities/Subscriber.php | 2 +- Entities/Subscription.php | 4 ++-- 10 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Entities/BillingCycle.php b/Entities/BillingCycle.php index 7350fd7..d13d9bd 100755 --- a/Entities/BillingCycle.php +++ b/Entities/BillingCycle.php @@ -44,13 +44,15 @@ class BillingCycle extends BaseModel public function fields(Blueprint $table = null): void { $this->fields = $table ?? new Blueprint($this->table); - + + $duration_type = ['minute' => 'Minute', 'hour' => 'Hour', 'day' => 'Day', 'week' => 'Week', 'month' => 'Month', 'year' => 'Year']; + $this->fields->increments('id')->html('text'); $this->fields->string('title')->html('text'); $this->fields->string('slug')->html('text'); $this->fields->string('description')->nullable()->html('textarea'); $this->fields->string('duration')->nullable()->html('number'); - $this->fields->enum('duration_type', ['minute', 'hour', 'day', 'week', 'month', 'year'])->default('month')->nullable()->html('switch'); + $this->fields->enum('duration_type', array_keys($duration_type))->options($duration_type)->default('month')->nullable()->html('switch'); $this->fields->boolean('published')->default(true)->nullable()->html('switch'); } diff --git a/Entities/MacAddress.php b/Entities/MacAddress.php index 927cf03..e16aab1 100755 --- a/Entities/MacAddress.php +++ b/Entities/MacAddress.php @@ -47,7 +47,7 @@ public function fields(Blueprint $table = null): void $this->fields = $table ?? new Blueprint($this->table); $this->fields->increments('id')->html('text'); - $this->fields->foreignId('subscriber_id')->nullable()->html('recordpicker')->table(['isp', 'subscriber']); + $this->fields->foreignId('subscriber_id')->nullable()->html('recordpicker')->relation(['isp', 'subscriber']); $this->fields->string('mac')->nullable()->html('text'); } diff --git a/Entities/Package.php b/Entities/Package.php index a23b41f..1e74e20 100755 --- a/Entities/Package.php +++ b/Entities/Package.php @@ -50,20 +50,23 @@ public function fields(Blueprint $table = null): void { $this->fields = $table ?? new Blueprint($this->table); + $speed_type = ['gigabyte' => 'Gigabyte', 'kilobyte' => 'Kilobyte', 'megabyte' => 'Megabyte']; + $speed_type_color = ['gigabyte' => 'green', 'kilobyte' => 'red', 'megabyte' => 'blue']; + $this->fields->increments('id')->html('text'); $this->fields->string('title')->html('text'); $this->fields->string('slug')->html('text'); $this->fields->string('pool')->html('text'); $this->fields->string('description')->nullable()->html('textarea'); - $this->fields->foreignId('billing_cycle_id')->nullable()->html('recordpicker')->table(['isp', 'billing_cycle']); - $this->fields->foreignId('gateway_id')->nullable()->html('recordpicker')->table(['isp', 'gateway']); + $this->fields->foreignId('billing_cycle_id')->nullable()->html('recordpicker')->relation(['isp', 'billing_cycle']); + $this->fields->foreignId('gateway_id')->nullable()->html('recordpicker')->relation(['isp', 'gateway']); $this->fields->string('speed')->nullable()->html('text'); - $this->fields->enum('speed_type', ['gigabyte', 'kilobyte', 'megabyte'])->default('megabyte')->nullable()->html('switch'); + $this->fields->enum('speed_type', array_keys($speed_type))->options($speed_type)->color($speed_type_color)->default('megabyte')->nullable()->html('switch'); $this->fields->string('bundle')->nullable()->html('text'); - $this->fields->enum('bundle_type', ['gigabyte', 'kilobyte', 'megabyte'])->default('megabyte')->nullable()->html('switch'); + $this->fields->enum('bundle_type', array_keys($speed_type))->options($speed_type)->color($speed_type_color)->default('megabyte')->nullable()->html('switch'); $this->fields->boolean('published')->default(1)->nullable()->html('switch'); $this->fields->boolean('featured')->default(0)->nullable()->html('switch'); diff --git a/Entities/PackageCharge.php b/Entities/PackageCharge.php index 86378c6..03b38d8 100755 --- a/Entities/PackageCharge.php +++ b/Entities/PackageCharge.php @@ -49,8 +49,8 @@ public function fields(Blueprint $table = null): void $this->fields->increments('id')->html('text'); $this->fields->string('title')->html('text'); $this->fields->string('slug')->html('text'); - $this->fields->foreignId('package_id')->html('recordpicker')->table(['isp', 'package']); - $this->fields->foreignId('ledger_id')->html('recordpicker')->table(['account', 'ledger']); + $this->fields->foreignId('package_id')->html('recordpicker')->relation(['isp', 'package']); + $this->fields->foreignId('ledger_id')->html('recordpicker')->relation(['account', 'ledger']); $this->fields->tinyInteger('quantity')->default(1)->html('text'); $this->fields->string('description')->nullable()->html('textarea'); $this->fields->double('price', 8, 2)->nullable()->html('number'); diff --git a/Entities/PackageChargeRate.php b/Entities/PackageChargeRate.php index ded092b..4b50740 100755 --- a/Entities/PackageChargeRate.php +++ b/Entities/PackageChargeRate.php @@ -47,8 +47,8 @@ public function fields(Blueprint $table = null): void $this->fields = $table ?? new Blueprint($this->table); $this->fields->increments('id')->html('text'); - $this->fields->foreignId('package_charge_id')->html('recordpicker')->table(['isp', 'package_charge']); - $this->fields->foreignId('rate_id')->html('recordpicker')->table(['account', 'rate']); + $this->fields->foreignId('package_charge_id')->html('recordpicker')->relation(['isp', 'package_charge']); + $this->fields->foreignId('rate_id')->html('recordpicker')->relation(['account', 'rate']); $this->fields->boolean('published')->default(true)->nullable()->html('switch'); } diff --git a/Entities/Payment.php b/Entities/Payment.php index d4a1f6f..a78b661 100755 --- a/Entities/Payment.php +++ b/Entities/Payment.php @@ -48,8 +48,8 @@ public function fields(Blueprint $table = null): void $this->fields->increments('id')->html('text'); $this->fields->string('title')->html('text'); - $this->fields->foreignId('subscription_id')->nullable()->html('recordpicker')->table(['isp', 'subscription']); - $this->fields->foreignId('invoice_id')->nullable()->html('recordpicker')->table(['account', 'invoice']); + $this->fields->foreignId('subscription_id')->nullable()->html('recordpicker')->relation(['isp', 'subscription']); + $this->fields->foreignId('invoice_id')->nullable()->html('recordpicker')->relation(['account', 'invoice']); $this->fields->string('description')->nullable()->html('textarea'); $this->fields->boolean('is_paid')->default(0)->nullable()->html('switch'); $this->fields->boolean('completed')->default(0)->nullable()->html('switch'); diff --git a/Entities/PaymentCharge.php b/Entities/PaymentCharge.php index 2880bf8..7106b6d 100755 --- a/Entities/PaymentCharge.php +++ b/Entities/PaymentCharge.php @@ -49,8 +49,8 @@ public function fields(Blueprint $table = null): void $this->fields->increments('id')->html('text'); $this->fields->string('title')->html('text'); $this->fields->string('slug')->html('text'); - $this->fields->foreignId('payment_id')->html('recordpicker')->table(['isp', 'payment']); - $this->fields->foreignId('ledger_id')->html('recordpicker')->table(['account', 'ledger']); + $this->fields->foreignId('payment_id')->html('recordpicker')->relation(['isp', 'payment']); + $this->fields->foreignId('ledger_id')->html('recordpicker')->relation(['account', 'ledger']); $this->fields->integer('quantity')->default(1)->html('number'); $this->fields->string('description')->nullable()->html('textarea'); $this->fields->double('price', 8, 2)->nullable()->html('number'); diff --git a/Entities/PaymentChargeRate.php b/Entities/PaymentChargeRate.php index 657d138..41de294 100755 --- a/Entities/PaymentChargeRate.php +++ b/Entities/PaymentChargeRate.php @@ -47,8 +47,8 @@ public function fields(Blueprint $table = null): void $this->fields = $table ?? new Blueprint($this->table); $this->fields->increments('id'); - $this->fields->foreignId('payment_charge_id')->html('recordpicker')->table(['isp', 'payment_charge']); - $this->fields->foreignId('rate_id')->html('recordpicker')->table(['account', 'rate']); + $this->fields->foreignId('payment_charge_id')->html('recordpicker')->relation(['isp', 'payment_charge']); + $this->fields->foreignId('rate_id')->html('recordpicker')->relation(['account', 'rate']); } } diff --git a/Entities/Subscriber.php b/Entities/Subscriber.php index 29a8d84..2a83a61 100755 --- a/Entities/Subscriber.php +++ b/Entities/Subscriber.php @@ -50,7 +50,7 @@ public function fields(Blueprint $table = null): void $this->fields->string('username')->unique()->html('text'); $this->fields->string('password')->html('text'); $this->fields->boolean('had_trail')->default(0)->nullable()->html('switch'); - $this->fields->foreignId('partner_id')->nullable()->html('recordpicker')->table(['partner']); + $this->fields->foreignId('partner_id')->nullable()->html('recordpicker')->relation(['partner']); } /** diff --git a/Entities/Subscription.php b/Entities/Subscription.php index 41920be..f24382a 100755 --- a/Entities/Subscription.php +++ b/Entities/Subscription.php @@ -49,8 +49,8 @@ public function fields(Blueprint $table = null): void $this->fields = $table ?? new Blueprint($this->table); $this->fields->increments('id')->html('text'); - $this->fields->foreignId('subscriber_id')->html('recordpicker')->table(['isp', 'subscriber']); - $this->fields->foreignId('package_id')->html('recordpicker')->table(['isp', 'package']); + $this->fields->foreignId('subscriber_id')->html('recordpicker')->relation(['isp', 'subscriber']); + $this->fields->foreignId('package_id')->html('recordpicker')->relation(['isp', 'package']); $this->fields->datetime('start_date')->html('datetime'); $this->fields->datetime('end_date')->html('datetime'); }