Skip to content

Commit

Permalink
adding option to enum for system display formkit
Browse files Browse the repository at this point in the history
  • Loading branch information
dedanirungu committed Aug 15, 2023
1 parent ecb08d0 commit b081d90
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 20 deletions.
6 changes: 4 additions & 2 deletions Entities/BillingCycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion Entities/MacAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
11 changes: 7 additions & 4 deletions Entities/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions Entities/PackageCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions Entities/PackageChargeRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
4 changes: 2 additions & 2 deletions Entities/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions Entities/PaymentCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions Entities/PaymentChargeRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

}
2 changes: 1 addition & 1 deletion Entities/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Entities/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit b081d90

Please sign in to comment.