Skip to content

Commit

Permalink
Adding structure function to model
Browse files Browse the repository at this point in the history
  • Loading branch information
dedanirungu committed Aug 15, 2023
1 parent ab54f0b commit 2e4fc83
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
17 changes: 15 additions & 2 deletions Entities/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class Gateway extends BaseModel
* @param Blueprint $table
* @return void
*/
public function fields(Blueprint $table): void
public function fields(Blueprint $table = null): void
{
$this->fields = $table ?? new Blueprint($this->table);

$this->fields->increments('id')->html('text');
$this->fields->string('title')->html('text');
$this->fields->string('slug')->html('text');
Expand All @@ -77,6 +77,19 @@ public function fields(Blueprint $table): void
$this->fields->tinyInteger('published')->nullable()->default(0)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['title', 'ledger_id', 'currency_id', 'consumer_key', 'consumer_secret', 'initiator_name', 'passkey', 'business_shortcode', 'phone_number', 'method', 'published'],
'filter' => ['ledger_id', 'currency_id'],
];

return $structure;
}

}

/**
Expand Down
17 changes: 15 additions & 2 deletions Entities/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class Payment extends BaseModel
* @param Blueprint $table
* @return void
*/
public function fields(Blueprint $table): void
public function fields(Blueprint $table = null): void
{
$this->fields = $table ?? new Blueprint($this->table);

$this->fields->increments('id')->html('text');
$this->fields->string('trans_type')->nullable()->html('text');
$this->fields->string('trans_id')->nullable()->html('text');
Expand All @@ -70,4 +70,17 @@ public function fields(Blueprint $table): void
$this->fields->tinyInteger('completed')->nullable()->default(0)->html('switch');
$this->fields->tinyInteger('successful')->nullable()->default(0)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['first_name', 'middle_name', 'last_name', 'msisdn', 'trans_type', 'trans_id', 'trans_time', 'trans_amount', 'business_short_code', 'bill_ref_number', 'invoice_number', 'completed', 'successful', 'published'],
'filter' => ['msisdn', 'trans_amount', 'business_short_code', 'bill_ref_number', 'invoice_number', 'completed', 'successful', 'published'],
];

return $structure;
}
}
15 changes: 14 additions & 1 deletion Entities/Simulate.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Simulate extends BaseModel
* @param Blueprint $table
* @return void
*/
public function fields(Blueprint $table): void
public function fields(Blueprint $table = null): void
{
$this->fields = $table ?? new Blueprint($this->table);

Expand All @@ -63,4 +63,17 @@ public function fields(Blueprint $table): void
$this->fields->tinyInteger('successful')->nullable()->default(0)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['amount', 'phone', 'reference', 'gateway_id', 'completed', 'successful'],
'filter' => ['amount', 'phone', 'reference', 'gateway_id', 'completed', 'successful'],
];

return $structure;
}

}
17 changes: 15 additions & 2 deletions Entities/Stkpush.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class Stkpush extends BaseModel
* @param Blueprint $table
* @return void
*/
public function fields(Blueprint $table): void
public function fields(Blueprint $table = null): void
{
$this->fields = $table ?? new Blueprint($this->table);

$this->fields->increments('id')->html('text');
$this->fields->string('amount')->html('text');
$this->fields->string('phone')->html('text');
Expand All @@ -64,4 +64,17 @@ public function fields(Blueprint $table): void
$this->fields->tinyInteger('completed')->nullable()->default(0)->html('switch');
$this->fields->tinyInteger('successful')->nullable()->default(0)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['amount', 'phone', 'reference', 'description', 'command', 'gateway_id', 'completed', 'successful', 'merchant_request_id', 'checkout_request_id'],
'filter' => ['amount', 'phone', 'reference', 'command', 'gateway_id', 'completed', 'successful'],
];

return $structure;
}
}
17 changes: 15 additions & 2 deletions Entities/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class Webhook extends BaseModel
* @param Blueprint $table
* @return void
*/
public function fields(Blueprint $table): void
public function fields(Blueprint $table = null): void
{
$this->fields = $table ?? new Blueprint($this->table);

$this->fields->increments('id')->html('text');
$this->fields->string('slug')->html('text');
$this->fields->string('validation_url')->html('text');
Expand All @@ -60,4 +60,17 @@ public function fields(Blueprint $table): void
$this->fields->string('shortcode')->html('text');
$this->fields->tinyInteger('published')->nullable()->default(0)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['slug', 'confirmation_url', 'validation_url', 'paybill_till', 'shortcode', 'published'],
'filter' => ['slug', 'confirmation_url', 'validation_url', 'paybill_till', 'published'],
];

return $structure;
}
}

0 comments on commit 2e4fc83

Please sign in to comment.