createCompany($request); // Create user $this->createUser($request); // Make the final touches $this->finalTouches(); // Redirect to dashboard return redirect('auth/login'); } private function createCompany($request) { // Create company $company = Company::create([ 'domain' => '', ]); // Set settings Setting::set([ 'general.company_name' => $request['company_name'], 'general.company_email' => $request['company_email'], 'general.default_currency' => 'USD', 'general.default_locale' => session('locale'), ]); Setting::setExtraColumns(['company_id' => $company->id]); Setting::save(); } private function createUser($request) { // Create the user $user = User::create([ 'name' => $request[''], 'email' => $request['user_email'], 'password' => $request['user_password'], 'locale' => session('locale'), ]); // Attach admin role $user->roles()->attach('1'); // Attach company $user->companies()->attach('1'); } private function finalTouches() { // Caching the config and route //Artisan::call('config:cache'); //Artisan::call('route:cache'); // Rename the robots.txt file try { File::move(base_path('robots.txt.dist'), base_path('robots.txt')); } catch (\Exception $e) { // nothing to do } } }