Merge remote-tracking branch 'origin/master'
# Conflicts: # skolehjem/app/MenuPlan.php
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAlbumsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('albums', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->foreignId('user_id')->constrained();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('albums');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateResourceExtensions extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('resource_extensions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string("extension")->unique();
|
||||
$table->text("description");
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('resource_extensions');
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
$this->call(PermissionSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,19 +40,79 @@ class PermissionSeeder extends Seeder
|
||||
"link.external.edit" => "Allows editing of external links.",
|
||||
"link.external.delete" => "Allows deletion of external links",
|
||||
|
||||
/**
|
||||
* The EVENT specific permissions
|
||||
*/
|
||||
"event.create" => "Create a new event",
|
||||
"event.list" => "Shows all events",
|
||||
"event.show" => "Shows a specific event",
|
||||
"event.edit" => "Allows editing of events",
|
||||
"event.delete" => "Allows deletion of events",
|
||||
|
||||
"contact.create" => "Creates a new contact",
|
||||
"contact.list" => "Shows all contacts",
|
||||
"contact.show" => "Shows a specific contact",
|
||||
"contact.edit" => "allows editing of contacts",
|
||||
"contact.delete" => "Allows deletion of contacts",
|
||||
|
||||
"feedback.create" => "Creates a new feedback message",
|
||||
"feedback.list" => "Shows all feedback messages",
|
||||
"feedback.show" => "Shows a specific feedback message",
|
||||
"feedback.edit" => "allows editing of feedback messages",
|
||||
"feedback.delete" => "allows deletion of feedback messages",
|
||||
|
||||
"menuplan.create" => "Create a new menuplan",
|
||||
"menuplan.list" => "Shows all menuplans",
|
||||
"menuplan.show" => "Shows a specific menuplan",
|
||||
"menuplan.edit" => "Allows editing of menuplans",
|
||||
"menuplan.delete" => "Allows deletion of menuplans",
|
||||
|
||||
"resource.category.create" => "Create a new resource category",
|
||||
"resource.category.list" => "Shows all resource categories",
|
||||
"resource.category.show" => "Shows a specific resource category",
|
||||
"resource.category.edit" => "Allows editing of resource categories",
|
||||
"resource.category.delete" => "Allows deletion of resource categories",
|
||||
|
||||
"resource.extension.create" => "Create a new resource extension",
|
||||
"resource.extension.list" => "Shows all resource extensions",
|
||||
"resource.extension.show" => "Shows a specific resource extension",
|
||||
"resource.extension.edit" => "Allows editing of resource extensions",
|
||||
"resource.extension.delete" => "Allows deletion of resource extensions",
|
||||
|
||||
"resource.create" => "Create a new resource",
|
||||
"resource.list" => "Shows all resources",
|
||||
"resource.show" => "Shows a specific resource",
|
||||
"resource.edit" => "Allows editing of resources",
|
||||
"resource.delete" => "Allows deletion of resources",
|
||||
|
||||
"washing.machine.create" => "Create a new washing machine",
|
||||
"washing.machine.list" => "Shows all washing machines",
|
||||
"washing.machine.show" => "Shows a specific washing machine",
|
||||
"washing.machine.edit" => "Allows editing of washing machines",
|
||||
"washing.machine.delete" => "Allows deletion of washing machines",
|
||||
|
||||
"washing.machine.reservation.create" => "Create a new washing machine reservation",
|
||||
"washing.machine.reservation.list" => "Shows all washing machine reservations",
|
||||
"washing.machine.reservation.show" => "Shows a specific washing machine reservation",
|
||||
"washing.machine.reservation.edit" => "Allows editing of washing machine reservations",
|
||||
"washing.machine.reservation.delete" => "Allows deletion of washing machine reservations",
|
||||
|
||||
|
||||
];
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
// try {
|
||||
//
|
||||
// } catch (Exception $e) {
|
||||
// }
|
||||
|
||||
Log::debug("YEET");
|
||||
|
||||
|
||||
if(User::where("name_first", "admin"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Log::debug("OPRET");
|
||||
$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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user