Lassi\App\Database::makeEloquent PHP Метод

makeEloquent() приватный Метод

Setup eloquent database
private makeEloquent ( Illuminate\Database\Capsule\Manager $capsule )
$capsule Illuminate\Database\Capsule\Manager
    private function makeEloquent(Capsule $capsule)
    {
        // Throw exception if minimum requirements not met
        if (!getenv('db_driver') || !getenv('db_name')) {
            throw new NotFoundException('App configurations not found.');
        }
        // Get capsule instance
        $this->setCapsule($capsule);
        // Cache db driver
        $db_driver = getenv('db_driver');
        // Setup connection defaults
        $configs = array('driver' => $db_driver, 'database' => getenv('db_name'), 'prefix' => getenv('db_prefix'), 'charset' => getenv('db_charset'), 'collation' => getenv('db_collation'));
        // Add extras depending on type of driver/connection
        if ($db_driver !== 'sqlite') {
            if (getenv('db_host')) {
                $configs['host'] = getenv('db_host');
            }
            if (getenv('db_username')) {
                $configs['username'] = getenv('db_username');
            }
            if (getenv('db_password')) {
                $configs['password'] = getenv('db_password');
            }
        }
        // Setup connection
        $this->getCapsule()->addConnection($configs);
        // Set as global
        $this->getCapsule()->setAsGlobal();
        // Boot eloquent
        $this->getCapsule()->bootEloquent();
        return $this;
    }