<commit_before><?php

namespace LaravelZero\Framework\Commands\Component\Illuminate\Database;

use LaravelZero\Framework\Commands\Component\AbstractComponentProvider;

/**
 * This is the Laravel Zero Framework illuminate/database component provider class.
 *
 * @author <NAME> <<EMAIL>>
 */
class ComponentProvider extends AbstractComponentProvider
{
    /**
     * {@inheritdoc}
     */
    public function isAvailable(): bool
    {
        return class_exists(\Illuminate\Database\DatabaseServiceProvider::class);
    }

    /**
     * {@inheritdoc}
     */
    public function register(): void
    {
        if (file_exists(config_path('database.php'))) {
            $this->mergeConfigFrom(config_path('database.php'), 'database');
        }

        $this->registerDatabaseService();

        $this->registerMigrationService();
    }

    /**
     * Registers the database service.
     *
     * Makes this Capsule instance available globally via static methods.
     *
     * @return void
     */
    protected function registerDatabaseService(): void
    {
        $this->registerServiceProvider(\Illuminate\Database\DatabaseServiceProvider::class);

        $this->app->alias('db', \Illuminate\Database\DatabaseManager::class);
        $this->app->alias('db', \Illuminate\Database\ConnectionResolverInterface::class);
        $this->app->alias('db.connection', \Illuminate\Database\DatabaseManager::class);
        $this->app->alias('db.connection', \Illuminate\Database\ConnectionInterface::class);

        $this->app->make(\Illuminate\Database\Capsule\Manager::class)
            ->setAsGlobal();

        if ($this->app->make('config')
            ->get('database.with-seeds', true)) {
            $this->commands(
                [
                    \Illuminate\Database\Console\Seeds\SeedCommand::class,
                    \Illuminate\Database\Console\Seeds\SeederMakeCommand::class,
                ]
            );

            if (is_dir(database_path('seeds'))) {
                collect(
                    $this->app->make('files')
                        ->files(database_path('seeds'))
                )->each(
                    function ($file) {
                        $this->app->make('files')
                            ->requireOnce($file);
                    }
                );
            }
        }
    }

    /**
     * Registers the migration service.
     *
     * @return void
     */
    protected function registerMigrationService(): void
    {
        $config = $this->app->make('config');
        $config->set('database.migrations', $config->get('database.migrations') ?: 'migrations');
        $this->registerServiceProvider(\Illuminate\Database\MigrationServiceProvider::class);
        $this->app->alias(
            'migration.repository',
            \Illuminate\Database\Migrations\MigrationRepositoryInterface::class
        );

        if ($this->app->make('config')
            ->get('database.with-migrations', true)) {
            $this->commands(
                [
                    \Illuminate\Database\Console\Migrations\FreshCommand::class,
                    \Illuminate\Database\Console\Migrations\InstallCommand::class,
                    \Illuminate\Database\Console\Migrations\MigrateCommand::class,
                    \Illuminate\Database\Console\Migrations\MigrateMakeCommand::class,
                    \Illuminate\Database\Console\Migrations\RefreshCommand::class,
                    \Illuminate\Database\Console\Migrations\ResetCommand::class,
                    \Illuminate\Database\Console\Migrations\RollbackCommand::class,
                    \Illuminate\Database\Console\Migrations\StatusCommand::class,
                ]
            );
        }
    }
}
<commit_msg>Removes make related commands from production env<commit_after><?php

namespace LaravelZero\Framework\Commands\Component\Illuminate\Database;

use LaravelZero\Framework\Commands\Component\AbstractComponentProvider;

/**
 * This is the Laravel Zero Framework illuminate/database component provider class.
 *
 * @author <NAME> <<EMAIL>>
 */
class ComponentProvider extends AbstractComponentProvider
{
    /**
     * {@inheritdoc}
     */
    public function isAvailable(): bool
    {
        return class_exists(\Illuminate\Database\DatabaseServiceProvider::class);
    }

    /**
     * {@inheritdoc}
     */
    public function register(): void
    {
        if (file_exists(config_path('database.php'))) {
            $this->mergeConfigFrom(config_path('database.php'), 'database');
        }

        $this->registerDatabaseService();

        $this->registerMigrationService();
    }

    /**
     * Registers the database service.
     *
     * Makes this Capsule instance available globally via static methods.
     *
     * @return void
     */
    protected function registerDatabaseService(): void
    {
        $this->registerServiceProvider(\Illuminate\Database\DatabaseServiceProvider::class);

        $this->app->alias('db', \Illuminate\Database\DatabaseManager::class);
        $this->app->alias('db', \Illuminate\Database\ConnectionResolverInterface::class);
        $this->app->alias('db.connection', \Illuminate\Database\DatabaseManager::class);
        $this->app->alias('db.connection', \Illuminate\Database\ConnectionInterface::class);

        $this->app->make(\Illuminate\Database\Capsule\Manager::class)->setAsGlobal();

        if (config('database.with-seeds', true)) {

            if ($this->app->environment() !== 'production') {
                $this->commands([\Illuminate\Database\Console\Seeds\SeederMakeCommand::class]);
            }

            $this->commands([\Illuminate\Database\Console\Seeds\SeedCommand::class]);

            if (is_dir(database_path('seeds'))) {
                collect(
                    $this->app->make('files')->files(database_path('seeds'))
                )->each(
                    function ($file) {
                        $this->app->make('files')->requireOnce($file);
                    }
                );
            }
        }
    }

    /**
     * Registers the migration service.
     *
     * @return void
     */
    protected function registerMigrationService(): void
    {
        $config = $this->app->make('config');
        $config->set('database.migrations', $config->get('database.migrations') ?: 'migrations');
        $this->registerServiceProvider(\Illuminate\Database\MigrationServiceProvider::class);
        $this->app->alias(
            'migration.repository',
            \Illuminate\Database\Migrations\MigrationRepositoryInterface::class
        );

        if (config('database.with-migrations', true)) {

            if ($this->app->environment() !== 'production') {
                $this->commands([\Illuminate\Database\Console\Migrations\MigrateMakeCommand::class]);
            }

            $this->commands(
                [
                    \Illuminate\Database\Console\Migrations\FreshCommand::class,
                    \Illuminate\Database\Console\Migrations\InstallCommand::class,
                    \Illuminate\Database\Console\Migrations\MigrateCommand::class,
                    \Illuminate\Database\Console\Migrations\RefreshCommand::class,
                    \Illuminate\Database\Console\Migrations\ResetCommand::class,
                    \Illuminate\Database\Console\Migrations\RollbackCommand::class,
                    \Illuminate\Database\Console\Migrations\StatusCommand::class,
                ]
            );
        }
    }
}

{'fraction_non_alphanumeric': 0.13421122638999733, 'fraction_numerical': 0.0, 'mean_word_length': 2.194137638062872, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4112249', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1936, 'n_words': 244}