Merge remote-tracking branch 'origin/master'

This commit is contained in:
frederikpyt
2020-06-30 09:19:56 +02:00
18 changed files with 175 additions and 86 deletions
@@ -13,6 +13,9 @@ class CreateUsersTable extends Migration
*/
public function up()
{
if(Schema::hasTable("users"))
return;
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name_first');
@@ -20,13 +20,17 @@ class CreatePermissionTables extends Migration
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('description');
$table->string('guard_name');
$table->timestamps();
});
if(!Schema::hasTable("permissions"))
{
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('description');
$table->string('guard_name');
$table->timestamps();
});
}
Schema::create($tableNames['roles'], function (Blueprint $table) {
$table->bigIncrements('id');
@@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateStaffTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('staff', function (Blueprint $table) {
$table->id();
$table->string('name_first');
$table->string('name_last');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->integer("phone")->unique();
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('staff');
}
}
@@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder
public function run()
{
$this->call(PermissionSeeder::class);
$this->call(UserSeeder::class);
}
}
+16 -6
View File
@@ -40,19 +40,29 @@ class PermissionSeeder extends Seeder
"link.external.edit" => "Allows editing of external links.",
"link.external.delete" => "Allows deletion of external links",
"event.create" => "Create a new event",
"event.list" => "Shows all events",
"event.show" => "Shows event",
"event.edit" => "Edit event",
"event.delete" => "Deletes an event",
"contact.create" => "Creates a new contact",
"contact.list" => ""
];
foreach ($permissions as $key => $value) {
if(Permission::findByName($key))
continue;
$permission = new Permission();
try {
if(Permission::findByName($key))
continue;
} catch (Exception $e) {
$permission = new Permission();
$permission->name = $key;
$permission->description = $value;
$permission->name = $key;
$permission->description = $value;
$permission->save();
$permission->save();
}
}
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$user = new \App\User();
$user->name_first = "admin";
$user->name_last = "admin";
$user->email = "admin@admin.local";
$user->setPasswordAttribute("1234");
$user->phone = 12345678;
foreach (\Spatie\Permission\Models\Permission::all() as $permission) {
$user->givePermissionTo($permission);
}
$user->save();
}
}