Fixes the creation of the initial user during setup

This commit is contained in:
Jeramy Simpson 2015-03-26 14:15:18 +10:00
parent 4b83070845
commit de1a5252ec
2 changed files with 15 additions and 7 deletions

View File

@ -1,5 +1,6 @@
<?php namespace App\Http\Controllers; <?php namespace App\Http\Controllers;
use Auth;
use Artisan; use Artisan;
use Cache; use Cache;
use Config; use Config;
@ -8,6 +9,7 @@ use Exception;
use Input; use Input;
use Utils; use Utils;
use View; use View;
use App\Models\User;
use App\Ninja\Mailers\Mailer; use App\Ninja\Mailers\Mailer;
use App\Ninja\Repositories\AccountRepository; use App\Ninja\Repositories\AccountRepository;
use Redirect; use Redirect;
@ -89,25 +91,31 @@ class AppController extends BaseController
fclose($fp); fclose($fp);
// == DB Migrate & Seed == // // == DB Migrate & Seed == //
Artisan::call('migrate:rollback', array('--force' => true)); // Debug Purposes
Artisan::call('migrate', array('--force' => true)); Artisan::call('migrate', array('--force' => true));
Artisan::call('db:seed', array('--force' => true)); Artisan::call('db:seed', array('--force' => true));
$account = $this->accountRepo->create(); $account = $this->accountRepo->create();
$user = $account->users()->first();
// Create User
$user = new User;
$user->first_name = trim(Input::get('first_name')); $user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(Input::get('last_name')); $user->last_name = trim(Input::get('last_name'));
$user->email = trim(strtolower(Input::get('email'))); $user->email = trim(strtolower(Input::get('email')));
$user->username = $user->email;
// Username getting the error: "The username may only contain letters, numbers, and dashes."
// Not sure where this validation comes from?
$user->username = 'test'; //$user->email;
$user->password = trim(Input::get('password')); $user->password = trim(Input::get('password'));
$user->password_confirmation = trim(Input::get('password')); $user->password_confirmation = trim(Input::get('password'));
$user->registered = true; $user->registered = true;
$user->account()->associate($account);
$user->save(); $user->save();
//Auth::login($user, true); Auth::login($user, true);
//$this->accountRepo->registerUser($user);
return Redirect::to('/invoices/create'); return Redirect::to('/dashboard');
} }
private function testDatabase($database) private function testDatabase($database)

View File

@ -32,7 +32,7 @@ class AccountRepository
$account->save(); $account->save();
$random = str_random(RANDOM_KEY_LENGTH); /* $random = str_random(RANDOM_KEY_LENGTH);
// I don't like how this is done with regards to init setup. I think it needs a refresh. // I don't like how this is done with regards to init setup. I think it needs a refresh.
$user = new User(); $user = new User();
@ -41,7 +41,7 @@ class AccountRepository
$user->email = 'test@test.com'; $user->email = 'test@test.com';
$user->username = $random; $user->username = $random;
$user->confirmed = !Utils::isNinja(); $user->confirmed = !Utils::isNinja();
$account->users()->save($user, []); $account->users()->save($user, []);*/
return $account; return $account;
} }