Skip to content

Commit

Permalink
👍 Make CRUD command
Browse files Browse the repository at this point in the history
  • Loading branch information
juzaweb committed Aug 5, 2023
1 parent 4d63051 commit 1407d7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 11 additions & 5 deletions modules/DevTool/Commands/Resource/CRUDMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Juzaweb\DevTool\Commands\Resource;

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Juzaweb\DevTool\Abstracts\CRUD\ResourceCommand;
Expand Down Expand Up @@ -60,9 +61,9 @@ public function handle(): void

$this->info('Add resource route '.$routePath);

$content = "Route::jwResource('{$table}', 'Backend\\{$model}Controller');";
$content = "Route::jwResource('{$this->getTableNameNonePrefix($table)}', {$model}Controller::class);";

//file_put_contents($routePath, PHP_EOL . $content . PHP_EOL, FILE_APPEND | LOCK_EX);
File::append($routePath, PHP_EOL . $content . PHP_EOL);

$this->info("Add to your route: {$content}");
}
Expand All @@ -86,11 +87,16 @@ protected function getTableColumns(string $table): array

protected function getModelNameByTable(string $table): string
{
$domain = $this->module->getDomainName();
$model = $this->getTableNameNonePrefix($table);

return Str::studly(Str::singular($model));
}

$model = Str::studly(Str::replace("{$domain}_", '', $table));
protected function getTableNameNonePrefix(string $table): string
{
$domain = $this->module->getDomainName();

return Str::singular($model);
return Str::replace("{$domain}_", '', $table);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions modules/DevTool/stubs/plugin/routes/admin.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@
| contains the "admin" middleware group. Now create something great!
|
*/


0 comments on commit 1407d7f

Please sign in to comment.