Skip to content

Commit

Permalink
Merge branch 'release/v2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenvh committed Jun 7, 2016
2 parents 8b57423 + 98b3a21 commit 281f663
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 8 additions & 9 deletions database/Migrations/2015_03_03_212000_create_users_table.php
Expand Up @@ -3,7 +3,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {
class CreateUsersTable extends Migration
{

/**
* @var array
Expand All @@ -22,7 +23,7 @@ public function __construct()
*/
public function up()
{
if(! Schema::hasTable('users')) {
if (! Schema::hasTable('users')) {
$this->createUsersTable();
} else {
$this->updateUSersTable();
Expand Down Expand Up @@ -98,17 +99,15 @@ private function fillFieldsArray()
*/
private function createUsersTable()
{
Schema::create('users', function($table)
{
foreach($this->fields as $field => $value) {
//$maxChars = (array_key_exists('length', $value)) ? ', ' . $value['length'] : null;
Schema::create('users', function ($table) {
foreach ($this->fields as $field => $value) {
$query = $table->$value['type']($field);

if (isset($value['extra'])) {
$query->$value['extra']();
}

}

$table->foreign('role_id')->references('id')->on('roles');
$table->timestamps();
$table->softDeletes();
Expand All @@ -121,8 +120,8 @@ private function createUsersTable()
*/
private function updateUSersTable()
{
Schema::table('users', function($table) {
foreach($this->fields as $field => $value) {
Schema::table('users', function ($table) {
foreach ($this->fields as $field => $value) {
if (!Schema::hasColumn('users', $field)) {
$query = $table->$value['type']($field);

Expand Down
4 changes: 3 additions & 1 deletion src/Controllers/Admin/DashboardController.php
Expand Up @@ -68,7 +68,9 @@ public function __construct(
$this->comment = $comment;
$this->tracert = $tracert;

$this->{"buildDataArrayFor".$this->auth_user->role->name}();
if ($this->auth_user) {
$this->{"buildDataArrayFor".$this->auth_user->role->name}();
}
}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 281f663

Please sign in to comment.