35 lines
787 B
PHP
35 lines
787 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Core\Commands;
|
||
|
|
|
||
|
|
class MakeModelCommand
|
||
|
|
{
|
||
|
|
public function execute(string $name, string $module): void
|
||
|
|
{
|
||
|
|
if (!$name || !$module) {
|
||
|
|
echo "Error: Model name and module are required\n";
|
||
|
|
echo "Usage: php artisan make:model <ModelName> <ModuleName>\n";
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$modulePath = __DIR__ . "/../../Modules/{$module}";
|
||
|
|
|
||
|
|
if (!is_dir($modulePath)) {
|
||
|
|
echo "Error: Module '{$module}' does not exist\n";
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$content = "<?php
|
||
|
|
|
||
|
|
namespace App\\Modules\\{$module};
|
||
|
|
|
||
|
|
class {$name}
|
||
|
|
{
|
||
|
|
// Add your model methods here
|
||
|
|
}";
|
||
|
|
|
||
|
|
file_put_contents("{$modulePath}/{$name}.php", $content);
|
||
|
|
echo "Model '{$name}' created in module '{$module}'!\n";
|
||
|
|
}
|
||
|
|
}
|