Create a Laravel application
496582
public function getApplication()
    {
        if (file_exists('bootstrap/autoload.php')) {
            require_once 'bootstrap/autoload.php';
        } elseif (file_exists('vendor/autoload.php')) {
            require_once 'vendor/autoload.php';
        }

        // Laravel 5 / Lumen
        $isLaravel = true;
        if (file_exists('bootstrap/app.php')) {
            $this->app = require_once 'bootstrap/app.php';
            if (substr($this->app->version(), 0, 5) === 'Lumen') {
                $isLaravel = false;
            }
        }

        // Laravel 4
        if (file_exists('bootstrap/start.php')) {
            $this->app = require_once 'bootstrap/start.php';
            $this->app->boot();

            return $this->app;
        }

        if (!$this->app) {
            throw new \RuntimeException('Laravel bootstrap file not found');
        }

        $kernel = $this->app->make($isLaravel ? 'Illuminate\Contracts\Http\Kernel' : 'Laravel\Lumen\Application');

        $this->app->afterResolving('auth', function ($auth) {
            $auth->extend('session', function ($app, $name, $config) {
                $provider = $app['auth']->createUserProvider($config['provider']);
                $guard = new \PHPPM\Laravel\SessionGuard($name, $provider, $app['session.store'], null, $app);
                if (method_exists($guard, 'setCookieJar')) {
                    $guard->setCookieJar($this->app['cookie']);
                }
                if (method_exists($guard, 'setDispatcher')) {
                    $guard->setDispatcher($this->app['events']);
                }
                if (method_exists($guard, 'setRequest')) {
                    $guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
                }

                return $guard;
            });
        });

        $app = $this->app;
        $this->app->extend('session.store', function () use ($app) {
            $manager = $app['session'];
            return $manager->driver();
        });

        return $kernel;
    }
508706
public function install()
    {
        $build = $this('mysql',
            $this->databases['default']['host'],
            '',
            $this->databases['default']['user'],
            $this->databases['default']['pass']);

        $main = $this('mysql',
            $this->databases['default']['host'],
            $this->databases['default']['name'],
            $this->databases['default']['user'],
            $this->databases['default']['pass']);

        $build->query('DROP DATABASE IF EXISTS `'.$this->databases['default']['name'].'`');
        $build->query('CREATE DATABASE `'.$this->databases['default']['name'].'`');

        //get schema
        $schema = $this('file', $this->cwd.'/schema.sql')->getContent();

        //add queries
        $queries = explode(';', $schema);

        $queries[] = "INSERT INTO `app` (
            `app_id`,
            `app_name`,
            `app_domain`,
            `app_token`,
            `app_secret`,
            `app_permissions`,
            `app_website`,
            `app_active`,
            `app_type`,
            `app_flag`,
            `app_created`,
            `app_updated`
        ) VALUES (
            1,
            'Main Application',
            '*.openovate.com',
            '986e7ce6bec660838491c1cd0a1f4ef6',
            'ba0d2fc7aab09dfa3463943c0aaa8551',
            '".implode(',', array(
                'public_profile',
                'public_sso',
                'personal_profile',
                'user_profile'
            ))."',
            'http://openovate.com/',
            1, NULL, 0, '2015-08-21 00:00:00', '2015-08-21 00:00:00'
        )";

        $queries[] = "INSERT INTO `auth` (
            `auth_id`,
            `auth_slug`,
            `auth_password`,
            `auth_token`,
            `auth_secret`,
            `auth_permissions`,
            `auth_facebook_token`,
            `auth_facebook_secret`,
            `auth_linkedin_token`,
            `auth_linkedin_secret`,
            `auth_twitter_token`,
            `auth_twitter_secret`,
            `auth_google_token`,
            `auth_google_secret`,
            `auth_active`,
            `auth_type`,
            `auth_flag`,
            `auth_created`,
            `auth_updated`
        ) VALUES (
            1,
            'admin@openovate.com',
            MD5('admin'),
            '986e7ce6bec660838491c1cd0a1f4ef6',
            'ba0d2fc7aab09dfa3463943c0aaa8551',
            '".implode(',', array(
                'public_profile',
                'public_sso',
                'personal_profile',
                'user_profile'
            ))."',
            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 0,
            '2015-09-11 23:05:17', '2015-09-11 23:05:17'
        )";

        $queries[] = "INSERT INTO `profile` (
            `profile_id`,
            `profile_name`,
            `profile_email`,
            `profile_phone`,
            `profile_detail`,
            `profile_company`,
            `profile_job`,
            `profile_gender`,
            `profile_birth`,
            `profile_website`,
            `profile_facebook`,
            `profile_linkedin`,
            `profile_twitter`,
            `profile_google`,
            `profile_active`,
            `profile_type`,
            `profile_flag`,
            `profile_created`,
            `profile_updated`
        ) VALUES (
            1,
            'Admin',
            'admin@openovate.com',
            '+63 (2) 654-5110',
            NULL, NULL, NULL, NULL, NULL,
            NULL, NULL, NULL, NULL, NULL, 1, NULL,
            0, '2015-09-11 23:05:16', '2015-09-11 23:05:16')";

        $queries[] = "INSERT INTO `app_profile` (`app_profile_app`, `app_profile_profile`) VALUES (1, 1)";
        $queries[] = "INSERT INTO `auth_profile` (`auth_profile_auth`, `auth_profile_profile`) VALUES (1, 1)";

        //now call the queries
        foreach($queries as $query) {
            $lines = explode("\n", $query);

            foreach($lines as $i => $line) {
                if(strpos($line, '--') === 0 || !trim($line)) {
                    unset($lines[$i]);
                    continue;
                }
            }

            $query = trim(implode("\n", $lines));

            if(!$query) {
                continue;
            }

            $main->query($query);
        }
    }
647056
private function create()
    {
        restoreRequest();
        $form = array(
            'name'=>'UserForm',
            'caption' => admUsersCreate,
            'width' => '400px',
            'fields' => array (
                array('type'=>'hidden','name'=>'action','value'=>'insert'),
                array('type'=>'edit','name'=>'name','label'=>admUsersName,'maxlength'=>32,'width'=>'100%',
                    'pattern'=>'/.+/', 'errormsg'=>admUsersNameInvalid),
                array('type'=>'edit','name'=>'login','label'=>admUsersLogin,'maxlength'=>16,'width'=>'100%',
                    'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admUsersLoginInvalid),
                array('type'=>'select','name'=>'access','label'=>admAccessLevel, 'width'=>'100%',
                    'values'=>array('2','3','4'),'items'=>array(ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4),
                    'default' => USER),
                array('type'=>'checkbox','name'=>'active','label'=>admUsersAccountState, 'default' => true),
                array('type'=>'divider'),
                array('type'=>'password','name'=>'pswd1','label'=>admUsersPassword,'maxlength'=>32,
                    'width'=>'100%'),
                array('type'=>'password','name'=>'pswd2','label'=>admUsersConfirmation,'maxlength'=>32,
                    'width'=>'100%', 'equal'=>'pswd1', 'errormsg'=>admUsersConfirmInvalid),
                array('type'=>'divider'),
                array('type' => 'edit', 'name' => 'mail' , 'label' => admUsersMail,
                    'maxlength' => 32, 'width' => '100%'),
            ),
            'buttons'=>array('ok', 'cancel')
        );

        /** @var TAdminUI $page */
        $page = Eresus_Kernel::app()->getPage();
        $result = $page->renderForm($form, Eresus_CMS::getLegacyKernel()->request['arg']);
        return $result;
    }
5467
public function boot()
    {
        $this->loadViewsFrom(__DIR__ . '/../../views', 'laravel-form-builder');

        $this->publishes([
            __DIR__ . '/../../views' => base_path('resources/views/vendor/laravel-form-builder'),
            __DIR__ . '/../../config/config.php' => config_path('laravel-form-builder.php')
        ]);

        $form = $this->app['form'];

        $form->macro('customLabel', function($name, $value, $options = []) use ($form) {
            if (isset($options['for']) && $for = $options['for']) {
                unset($options['for']);
                return $form->label($for, $value, $options);
            }

            return $form->label($name, $value, $options);
        });
    }
157750
public function boot()
    {
        $configPath = __DIR__.'/../../config/config.php';
        $configKey = 'localization-js';

        // Determines Laravel major version.
        $app = $this->app;
        $laravelMajorVersion = (int) $app::VERSION;

        // Publishes Laravel-JS-Localization package files and merge user and
        // package configurations.
        if ($laravelMajorVersion === 4) {
            $config = $this->app['config']->get($configKey, []);
            $this->app['config']->set($configKey, array_merge(require $configPath, $config));
        } elseif ($laravelMajorVersion === 5) {
            $this->publishes([
                $configPath => config_path("$configKey.php"),
            ]);
            $this->mergeConfigFrom(
                $configPath, $configKey
            );
        }
    }
562102
public function run()
    {
        // php artisan db:seed --class="PermissionsTableSeeder"
        $permissions = [
            [
                'name' => 'manage_users',
            ],
            [
                'name' => 'manage_pages',
            ],
            [
                'name' => 'access_admin',
            ],
        ];

        // Only add new
        $allPermissions = Permission::all()->pluck('name')->toArray();

        foreach ($permissions as $permission) {
            if (! in_array($permission['name'], $allPermissions)) {
                Permission::create($permission);
            }
        }
    }
900804
public function boot()
    {
        // routes
        if (!$this->app->routesAreCached()) {
            require __DIR__ . '/Http/routes.php';
        }

        // views
        $this->loadViewsFrom(__DIR__ . '/Views', 'visitlog');

        // publish our files over to main laravel app
        $this->publishes([
            __DIR__ . '/Config/visitlog.php' => config_path('visitlog.php'),
            __DIR__ . '/Migrations' => database_path('migrations')
        ]);
    }
1168592
public function createRepository()
	{
		$client = $this->getConnection()->getClient();

		$client->makeClass($this->table, function($table)
		{
			// The migrations table is responsible for keeping track of which of the
			// migrations have actually run for the application. We'll create the
			// table to hold the migration file's path as well as the version ID.
			$table->string('migration');

			$table->integer('version');
		})->save();
	}
1123574
public function register()
    {
        $this->app->register(ScaffoldInterfaceEventServiceProvider::class);

        $this->app->singleton('laravelRequest', \Illuminate\Http\Request::class);

        $this->app->singleton('Request', \Amranidev\ScaffoldInterface\Http\Request::class);

        $this->app->singleton('Scaffold', \Amranidev\ScaffoldInterface\Scaffold::class);

        $this->app->singleton('Datasystem', function ($app) {
            return new \Amranidev\ScaffoldInterface\Datasystem\Datasystem($app->make('Request')->getRequest());
        });

        $this->app->singleton('Parser', function ($app) {
            return new \Amranidev\ScaffoldInterface\Parsers\Parser($app->make('Request')->getRequest());
        });

        $this->app->singleton('Indenter', \Gajus\Dindent\Indenter::class);

        $this->app->singleton('Path', \Amranidev\ScaffoldInterface\Filesystem\Path::class);

        $this->app->singleton('Generator', \Amranidev\ScaffoldInterface\Generators\Generator::class);

        $this->app->singleton('ModelGenerate', \Amranidev\ScaffoldInterface\Generators\ModelGenerate::class);

        $this->app->singleton('ViewGenerate', \Amranidev\ScaffoldInterface\Generators\ViewGenerate::class);

        $this->app->singleton('MigrationGenerate', \Amranidev\ScaffoldInterface\Generators\MigrationGenerate::class);

        $this->app->singleton('ControllerGenerate', \Amranidev\ScaffoldInterface\Generators\ControllerGenerate::class);

        $this->app->singleton('RouteGenerate', \Amranidev\ScaffoldInterface\Generators\RouteGenerate::class);
    }
846121
private function createView(): void
    {
        $path = $this->getViewPath();

        if ($this->files->exists($path)) {
            $this->error($this->qualifyClass($this->getNameInput()).'View.blade.php - Already exists! (@_@)');

            return;
        }

        $this->files->put($path, $this->getViewStub());

        $this->info(' - '.$this->qualifyClass($this->getNameInput()).'View.blade.php - was created. (^_^)');

        $this->printStarUs();
    }
546194
private function registerOAuthApp()
    {
        $oauth = new OAuthApp();
        $this->app->instance(\Acacha\LaravelSocial\Services\OAuthApp::class, $oauth);
    }
438575
public function run()
    {
        $baseName = str_slug(basename(base_path()), '-');
        if ($baseName == 'src') {
            $baseName = str_slug(basename(dirname(base_path())), '-');
        }

        $application = Application::withoutGlobalScopes()->firstOrCreate([
            'name' => ucwords(str_replace('-', ' ', $baseName)),
        ]);

        ApplicationUrl::withoutGlobalScopes()->firstOrCreate([
            'domain'         => $baseName.'.test',
            'application_id' => $application->getKey(),
        ]);
    }
114013
public function boot()
    {
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'admin');

        if (file_exists($routes = admin_path('routes.php'))) {
            $this->loadRoutesFrom($routes);
        }

        if ($this->app->runningInConsole()) {
            $this->publishes([__DIR__.'/../config' => config_path()], 'laramanager-config');
            $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang')], 'laramanager-lang');
            //$this->publishes([__DIR__.'/../resources/views' => resource_path('views/admin')], 'laramanager-views');
            $this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'laramanager-migrations');
            $this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/laramanager')], 'laramanager-assets');
            $this->publishes([__DIR__.'/../resources/images' => public_path('images')], 'laramanager-images');
        }

        //remove default feature of double encoding enable in laravel 5.6 or later.
        $bladeReflectionClass = new \ReflectionClass('\Illuminate\View\Compilers\BladeCompiler');
        if ($bladeReflectionClass->hasMethod('withoutDoubleEncoding')) {
            Blade::withoutDoubleEncoding();
        }
    }
1216991
public function up()
    {
        $config = config('laravel-permission.table_names');

        Schema::create($config['roles'], function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->timestamps();
        });

        Schema::create($config['permissions'], function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->timestamps();
        });

        Schema::create($config['user_has_permissions'], function (Blueprint $table) use ($config) {
            $table->integer('user_id')->unsigned();
            $table->integer('permission_id')->unsigned();

            $table->foreign('user_id')
                ->references('id')
                ->on($config['users'])
                ->onDelete('cascade');

            $table->foreign('permission_id')
                ->references('id')
                ->on($config['permissions'])
                ->onDelete('cascade');

            $table->primary(['user_id', 'permission_id']);
        });

        Schema::create($config['user_has_roles'], function (Blueprint $table) use ($config) {
            $table->integer('role_id')->unsigned();
            $table->integer('user_id')->unsigned();

            $table->foreign('role_id')
                ->references('id')
                ->on($config['roles'])
                ->onDelete('cascade');

            $table->foreign('user_id')
                ->references('id')
                ->on($config['users'])
                ->onDelete('cascade');

            $table->primary(['role_id', 'user_id']);

            Schema::create($config['role_has_permissions'], function (Blueprint $table) use ($config) {
                $table->integer('permission_id')->unsigned();
                $table->integer('role_id')->unsigned();

                $table->foreign('permission_id')
                    ->references('id')
                    ->on($config['permissions'])
                    ->onDelete('cascade');

                $table->foreign('role_id')
                    ->references('id')
                    ->on($config['roles'])
                    ->onDelete('cascade');

                $table->primary(['permission_id', 'role_id']);
            });
        });
    }
1304868
protected function createController()
    {
        Artisan::call('make:controller', [
            'name' => $controller = $this->controllerWithoutMethod($this->action())
        ]);
        $this->addMethodToController($controller, $this->controllerMethod($this->action()));
        $this->info('Controller ' . $controller .' created.');
        $this->createView($this->argument('link'));
    }
307119
protected function createMigration()
    {
        $migrationPath = $this->getMigrationPath();

        $output = $this->laravel->view
            ->make('laratrust::migration')
            ->with(['laratrust' => Config::get('laratrust')])
            ->render();

        if (!file_exists($migrationPath) && $fs = fopen($migrationPath, 'x')) {
            fwrite($fs, $output);
            fclose($fs);
            return true;
        }

        return false;
    }
30691
public function boot()
	{
		$this->app['less'] = $this->app->share(function($app)
		{
			$config = $app['config'];
            if (isset($app['html'])) {
                $builder = $app['html'];
            } else {
                // if the app hasn't set up Laravel's HTML package, we'd better just instantiate a version
                $builder = new HtmlBuilder($app['url']);
            }
			return new Less($config,$builder);
		});
        $this->publishes([
            __DIR__.'/config/config.php' => config_path('less4laravel.php'),
        ]);
	}