Skip to content

Commit 415f4a0

Browse files
committed
adding listtable and formbuilder fuction to all model so that data can be rendered via json
1 parent 13c8ad9 commit 415f4a0

21 files changed

+572
-43
lines changed

Classes/Freeradius.php

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class Freeradius
1717
public function __construct()
1818
{
1919
$gateway = Gateway::where(['type' => 'freeradius', 'published' => true])->first();
20+
21+
if(defined('MYBIZNA_MIGRATION') && MYBIZNA_MIGRATION) {
22+
return;
23+
}
2024

2125
if (!$gateway) {
2226
throw new \Exception("No Freeradius gateway set.", 1);

Entities/BillingCycle.php

+46
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,59 @@
55
use Modules\Base\Entities\BaseModel;
66
use Illuminate\Database\Schema\Blueprint;
77

8+
use Modules\Core\Classes\Views\ListTable;
9+
use Modules\Core\Classes\Views\FormBuilder;
10+
811
class BillingCycle extends BaseModel
912
{
1013

1114
protected $fillable = ['title', 'slug', 'description', 'duration', 'duration_type', 'published'];
1215
public $migrationDependancy = [];
1316
protected $table = "isp_billing_cycle";
1417

18+
19+
public function listTable(){
20+
// listing view fields
21+
$fields = new ListTable();
22+
23+
$fields->name('title')->type('text')->ordering(true);
24+
$fields->name('slug')->type('text')->ordering(true);
25+
$fields->name('duration')->type('text')->ordering(true);
26+
$fields->name('duration_type')->type('text')->ordering(true);
27+
$fields->name('published')->type('switch')->ordering(true);
28+
29+
30+
return $fields;
31+
32+
}
33+
34+
public function formBuilder(){
35+
// listing view fields
36+
$fields = new FormBuilder();
37+
38+
$fields->name('title')->type('text')->group('w-1/2');
39+
$fields->name('slug')->type('text')->group('w-1/2');
40+
$fields->name('duration')->type('text')->group('w-1/2');
41+
$fields->name('duration_type')->type('text')->group('w-1/2');
42+
$fields->name('published')->type('switch')->group('w-1/2');
43+
$fields->name('description')->type('textarea')->group('w-full');
44+
45+
return $fields;
46+
47+
}
48+
49+
public function filter(){
50+
// listing view fields
51+
$fields = new FormBuilder();
52+
53+
$fields->name('title')->type('text')->group('w-1/6');
54+
$fields->name('slug')->type('text')->group('w-1/6');
55+
$fields->name('duration')->type('text')->group('w-1/6');
56+
$fields->name('duration_type')->type('text')->group('w-1/6');
57+
58+
return $fields;
59+
60+
}
1561
/**
1662
* List of fields for managing postings.
1763
*

Entities/Gateway.php

+51
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,64 @@
55
use Modules\Base\Entities\BaseModel;
66
use Illuminate\Database\Schema\Blueprint;
77

8+
use Modules\Core\Classes\Views\ListTable;
9+
use Modules\Core\Classes\Views\FormBuilder;
10+
811
class Gateway extends BaseModel
912
{
1013

1114
protected $fillable = ['title', 'username', 'password', 'database', 'ip_address', 'port', 'type', 'published'];
1215
public $migrationDependancy = [];
1316
protected $table = "isp_gateway";
1417

18+
19+
public function listTable(){
20+
// listing view fields
21+
$fields = new ListTable();
22+
23+
$fields->name('title')->type('text')->ordering(true);
24+
$fields->name('username')->type('text')->ordering(true);
25+
$fields->name('database')->type('text')->ordering(true);
26+
$fields->name('ip_address')->type('text')->ordering(true);
27+
$fields->name('port')->type('text')->ordering(true);
28+
$fields->name('type')->type('text')->ordering(true);
29+
$fields->name('published')->type('switch')->ordering(true);
30+
31+
32+
33+
return $fields;
34+
35+
}
36+
37+
public function formBuilder(){
38+
// listing view fields
39+
$fields = new FormBuilder();
40+
41+
$fields->name('title')->type('text')->group('w-1/2');
42+
$fields->name('username')->type('text')->group('w-1/2');
43+
$fields->name('password')->type('text')->group('w-1/2');
44+
$fields->name('database')->type('text')->group('w-1/2');
45+
$fields->name('ip_address')->type('text')->group('w-1/2');
46+
$fields->name('port')->type('text')->group('w-1/2');
47+
$fields->name('type')->type('text')->group('w-1/2');
48+
$fields->name('published')->type('switch')->group('w-1/2');
49+
50+
return $fields;
51+
52+
}
53+
54+
public function filter(){
55+
// listing view fields
56+
$fields = new FormBuilder();
57+
58+
$fields->name('title')->type('text')->group('w-1/6');
59+
$fields->name('username')->type('text')->group('w-1/6');
60+
$fields->name('ip_address')->type('text')->group('w-1/6');
61+
$fields->name('port')->type('text')->group('w-1/6');
62+
63+
return $fields;
64+
65+
}
1566
/**
1667
* List of fields for managing postings.
1768
*

Entities/MacAddress.php

+36
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,49 @@
66
use Modules\Base\Classes\Migration;
77
use Modules\Base\Entities\BaseModel;
88

9+
use Modules\Core\Classes\Views\ListTable;
10+
use Modules\Core\Classes\Views\FormBuilder;
11+
912
class MacAddress extends BaseModel
1013
{
1114

1215
protected $fillable = ['subscriber_id', 'mac'];
1316
public $migrationDependancy = ['isp_subscriber'];
1417
protected $table = "isp_mac_address";
1518

19+
20+
public function listTable(){
21+
// listing view fields
22+
$fields = new ListTable();
23+
24+
$fields->name('subscriber_id')->type('recordpicker')->table('isp_subscriber')->ordering(true);
25+
$fields->name('mac')->type('text')->ordering(true);
26+
27+
return $fields;
28+
29+
}
30+
31+
public function formBuilder(){
32+
// listing view fields
33+
$fields = new FormBuilder();
34+
35+
$fields->name('subscriber_id')->type('recordpicker')->table('isp_subscriber')->group('w-1/2');
36+
$fields->name('mac')->type('text')->group('w-1/2');
37+
38+
return $fields;
39+
40+
}
41+
42+
public function filter(){
43+
// listing view fields
44+
$fields = new FormBuilder();
45+
46+
$fields->name('subscriber_id')->type('recordpicker')->table('isp_subscriber')->group('w-1/6');
47+
$fields->name('mac')->type('text')->group('w-1/6');
48+
49+
return $fields;
50+
51+
}
1652
/**
1753
* List of fields for managing postings.
1854
*

Entities/Package.php

+56
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use Modules\Base\Classes\Migration;
77
use Modules\Base\Entities\BaseModel;
88

9+
use Modules\Core\Classes\Views\ListTable;
10+
use Modules\Core\Classes\Views\FormBuilder;
11+
912
class Package extends BaseModel
1013
{
1114

@@ -17,6 +20,59 @@ class Package extends BaseModel
1720
public $migrationDependancy = ['isp_billing_cycle'];
1821
protected $table = "isp_package";
1922

23+
24+
public function listTable(){
25+
// listing view fields
26+
$fields = new ListTable();
27+
28+
$fields->name('title')->type('text')->ordering(true);
29+
$fields->name('slug')->type('text')->ordering(true);
30+
$fields->name('pool')->type('text')->ordering(true);
31+
$fields->name('billing_cycle_id')->type('recordpicker')->table('isp_billing_cycle')->ordering(true);
32+
$fields->name('gateway_id')->type('recordpicker')->table('isp_gateway')->ordering(true);
33+
$fields->name('speed')->type('text')->ordering(true);
34+
$fields->name('speed_type')->type('text')->ordering(true);
35+
$fields->name('bundle')->type('text')->ordering(true);
36+
$fields->name('bundle_type')->type('text')->ordering(true);
37+
$fields->name('published')->type('switch')->ordering(true);
38+
39+
return $fields;
40+
41+
}
42+
43+
public function formBuilder(){
44+
// listing view fields
45+
$fields = new FormBuilder();
46+
47+
$fields->name('title')->type('text')->group('w-1/2');
48+
$fields->name('slug')->type('text')->group('w-1/2');
49+
$fields->name('pool')->type('text')->group('w-1/2');
50+
$fields->name('billing_cycle_id')->type('recordpicker')->table('isp_billing_cycle')->group('w-1/2');
51+
$fields->name('gateway_id')->type('recordpicker')->table('isp_gateway')->group('w-1/2');
52+
$fields->name('speed')->type('text')->group('w-1/2');
53+
$fields->name('speed_type')->type('text')->group('w-1/2');
54+
$fields->name('bundle')->type('text')->group('w-1/2');
55+
$fields->name('bundle_type')->type('text')->group('w-1/2');
56+
$fields->name('published')->type('switch')->group('w-1/2');
57+
$fields->name('description')->type('textarea')->group('w-full');
58+
59+
return $fields;
60+
61+
}
62+
63+
public function filter(){
64+
// listing view fields
65+
$fields = new FormBuilder();
66+
67+
$fields->name('title')->type('text')->group('w-1/6');
68+
$fields->name('slug')->type('text')->group('w-1/6');
69+
$fields->name('pool')->type('text')->group('w-1/6');
70+
$fields->name('billing_cycle_id')->type('recordpicker')->table('isp_billing_cycle')->group('w-1/6');
71+
$fields->name('gateway_id')->type('recordpicker')->table('isp_gateway')->group('w-1/6');
72+
73+
return $fields;
74+
75+
}
2076
/**
2177
* List of fields for managing postings.
2278
*

Entities/PackageCharge.php

+57
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,70 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Modules\Base\Classes\Migration;
88

9+
use Modules\Core\Classes\Views\ListTable;
10+
use Modules\Core\Classes\Views\FormBuilder;
11+
12+
913
class PackageCharge extends BaseModel
1014
{
1115

1216
protected $fillable = ['title', 'slug', 'description', 'package_id', 'ledger_id', 'price','quantity', 'published'];
1317
public $migrationDependancy = ['isp_package', 'account_ledger'];
1418
protected $table = "isp_package_charge";
1519

20+
21+
public function listTable(){
22+
// listing view fields
23+
$fields = new ListTable();
24+
25+
$fields->name('title')->type('text')->ordering(true);
26+
$fields->name('slug')->type('text')->ordering(true);
27+
$fields->name('package_id')->type('recordpicker')->table('isp_package')->ordering(true);
28+
$fields->name('ledger_id')->type('recordpicker')->table('account_ledger')->ordering(true);
29+
$fields->name('quantity')->type('text')->ordering(true);
30+
$fields->name('description')->type('textarea')->ordering(true);
31+
$fields->name('price')->type('text')->ordering(true);
32+
$fields->name('published')->type('switch')->ordering(true);
33+
34+
35+
return $fields;
36+
37+
}
38+
39+
public function formBuilder(){
40+
// listing view fields
41+
$fields = new FormBuilder();
42+
43+
$fields->name('title')->type('text')->group('w-1/2');
44+
$fields->name('slug')->type('text')->group('w-1/2');
45+
$fields->name('package_id')->type('recordpicker')->table('isp_package')->group('w-1/2');
46+
$fields->name('ledger_id')->type('recordpicker')->table('account_ledger')->group('w-1/2');
47+
$fields->name('quantity')->type('text')->group('w-1/2');
48+
$fields->name('description')->type('textarea')->group('w-full');
49+
$fields->name('price')->type('text')->group('w-1/2');
50+
$fields->name('published')->type('switch')->group('w-1/2');
51+
52+
53+
return $fields;
54+
55+
}
56+
57+
public function filter(){
58+
// listing view fields
59+
$fields = new FormBuilder();
60+
61+
$fields->name('title')->type('text')->group('w-1/6');
62+
$fields->name('slug')->type('text')->group('w-1/6');
63+
$fields->name('package_id')->type('recordpicker')->table('isp_package')->group('w-1/6');
64+
$fields->name('ledger_id')->type('recordpicker')->table('account_ledger')->group('w-1/6');
65+
$fields->name('quantity')->type('text')->group('w-1/6');
66+
$fields->name('price')->type('text')->group('w-1/6');
67+
$fields->name('published')->type('switch')->group('w-1/6');
68+
69+
70+
return $fields;
71+
72+
}
1673
/**
1774
* List of fields for managing postings.
1875
*

Entities/PackageChargeRate.php

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Modules\Base\Classes\Migration;
88

9+
use Modules\Core\Classes\Views\ListTable;
10+
use Modules\Core\Classes\Views\FormBuilder;
11+
912
class PackageChargeRate extends BaseModel
1013
{
1114

0 commit comments

Comments
 (0)