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 6b3eb89 commit add7a1c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
17 changes: 15 additions & 2 deletions Entities/Autoresponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Autoresponder 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('subject')->html('text');
$this->fields->string('body')->html('textarea');
Expand All @@ -58,4 +58,17 @@ public function fields(Blueprint $table): void
$this->fields->tinyInteger('published')->default(true)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['subject', 'wait_period', 'table_name', 'email_field', 'date_field', 'start_date', 'end_date', 'published'],
'filter' => ['subject', 'start_date', 'end_date', 'published'],
];

return $structure;
}

}
15 changes: 14 additions & 1 deletion Entities/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Campaign 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 @@ -52,4 +52,17 @@ public function fields(Blueprint $table): void
$this->fields->tinyInteger('is_sent')->nullable()->default(0)->html('switch');
$this->fields->tinyInteger('published')->nullable()->default(1)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['subject', 'send_date', 'is_sent', 'published'],
'filter' => ['subject', 'send_date', 'is_sent', 'published'],
];

return $structure;
}
}
17 changes: 15 additions & 2 deletions Entities/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,27 @@ class Group 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->char('name', 255)->html('text');
$this->fields->string('description')->html('textarea');
$this->fields->integer('ordering')->html('text');
$this->fields->tinyInteger('published')->default(true)->html('switch');
}

/**
* List of structure for this model.
*/
public function structure($structure): array
{
$structure = [
'table' => ['name', 'ordering', 'published'],
'filter' => ['name', 'published'],
];

return $structure;
}
}

0 comments on commit add7a1c

Please sign in to comment.