Skip to content

Commit

Permalink
Merge pull request #4 from tomatophp/develop
Browse files Browse the repository at this point in the history
fix icon picker package & add feature to change database tables prefix
  • Loading branch information
3x1io authored Apr 17, 2024
2 parents bd549ea + 06f8034 commit 7f793f6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"tomatophp/console-helpers": "^1.1",
"filament/filament": "^3.0.0",
"filament/notifications": "^3.0.0",
"nwidart/laravel-modules": "^11.0"
"nwidart/laravel-modules": "^11.0",
"guava/filament-icon-picker": "^2.2"
}
}
4 changes: 3 additions & 1 deletion config/filament-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"allow_generator" => true,
"clusters" => [
"enabled" => true
]
],

'database_prefix' => null
];

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function up(): void
{
Schema::create('tables', function (Blueprint $table) {
Schema::create(config('filament-plugins.database_prefix') ? config('filament-plugins.database_prefix') . '_tables' : 'tables', function (Blueprint $table) {
$table->id();

//Link To Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/
public function up(): void
{
Schema::create('table_cols', function (Blueprint $table) {
Schema::create(config('filament-plugins.database_prefix') ? config('filament-plugins.database_prefix') . '_table_cols' : 'table_cols', function (Blueprint $table) {
$table->id();

$table->foreignId('table_id')->constrained('tables')->cascadeOnDelete();
$table->foreignId('table_id')->constrained(config('filament-plugins.database_prefix') ? config('filament-plugins.database_prefix') . '_tables' : 'tables')->cascadeOnDelete();

$table->string('name');
$table->string('type')->default('varchar')->nullable();
Expand Down
5 changes: 5 additions & 0 deletions src/Models/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public function migrate()
$generator = new CRUDGenerator(table: $this, migration: true);
$generator->generate();
}

public function getTable()
{
return config('filament-plugins.database_prefix') ? config('filament-plugins.database_prefix') . '_tables' : 'tables';
}
}
5 changes: 5 additions & 0 deletions src/Models/TableCol.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ public function table()
{
return $this->belongsTo('TomatoPHP\FilamentPlugins\Models\Table');
}

public function getTable()
{
return config('filament-plugins.database_prefix') ? config('filament-plugins.database_prefix') . '_table_cols' : 'table_cols';
}
}

0 comments on commit 7f793f6

Please sign in to comment.