From 715b188ecd983cfa38847bc7cb629a1c497c5e1d Mon Sep 17 00:00:00 2001 From: Vedran Zelen <zelenvedran@gmail.com> Date: Mon, 27 Jul 2020 13:24:35 +0200 Subject: [PATCH 1/3] removed useless comment --- skolehjem/app/Http/Controllers/ContactController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skolehjem/app/Http/Controllers/ContactController.php b/skolehjem/app/Http/Controllers/ContactController.php index 7abfc08..e649834 100644 --- a/skolehjem/app/Http/Controllers/ContactController.php +++ b/skolehjem/app/Http/Controllers/ContactController.php @@ -6,7 +6,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use App\Contact; use phpDocumentor\Reflection\Types\Context; -//hello + class ContactController extends Controller { public function __construct() From fb65c1b9fc23a27b373427430130181de5d9e151 Mon Sep 17 00:00:00 2001 From: Sebastian <seba4928@edu.sde.dk> Date: Tue, 28 Jul 2020 08:18:45 +0200 Subject: [PATCH 2/3] Added UserEvent.php --- .../app/Http/Controllers/UserController.php | 2 +- skolehjem/app/UserEvent.php | 10 +++++ ...7_01_064330_create_resource_categories.php | 4 +- ..._07_28_061420_create_user_events_table.php | 37 +++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 skolehjem/app/UserEvent.php create mode 100644 skolehjem/database/migrations/2020_07_28_061420_create_user_events_table.php diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index 7e3be4d..7d76618 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -286,7 +286,7 @@ class UserController extends Controller "<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/pencil.svg\" alt=\"Update\"></th>". "<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>". "</tr>"; - $users = DB::table('users')->where('name_first', 'LIKE',$request->search.'%') + $users = User::query()->where('name_first', 'LIKE',$request->search.'%') ->orWhere('name_last','LIKE', $request->search.'%') ->orWhere('phone','LIKE', $request->search.'%') ->orWhere('email','LIKE',$request->search. '%')->get(); diff --git a/skolehjem/app/UserEvent.php b/skolehjem/app/UserEvent.php new file mode 100644 index 0000000..3899fd5 --- /dev/null +++ b/skolehjem/app/UserEvent.php @@ -0,0 +1,10 @@ +<?php + +namespace App; + +use Illuminate\Database\Eloquent\Model; + +class UserEvent extends Model +{ + // +} diff --git a/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php b/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php index 290931b..8399305 100644 --- a/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php +++ b/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php @@ -13,13 +13,13 @@ class CreateResourceCategories extends Migration */ public function up() { - Schema::create('resource_categories', function (Blueprint $table) { + /*Schema::create('resource_categories', function (Blueprint $table) { $table->id(); $table->string("name")->unique(); $table->text("description"); $table->string("slug")->unique(); $table->timestamps(); - }); + });*/ } /** diff --git a/skolehjem/database/migrations/2020_07_28_061420_create_user_events_table.php b/skolehjem/database/migrations/2020_07_28_061420_create_user_events_table.php new file mode 100644 index 0000000..e129f3c --- /dev/null +++ b/skolehjem/database/migrations/2020_07_28_061420_create_user_events_table.php @@ -0,0 +1,37 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateUserEventsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('user_events', function (Blueprint $table) { + $table->id(); + $table->integer("user_id")->unique(); + $table->integer("event_id")->unique(); + + $table->timestamps(); + + $table->foreign("user_id")->references("id")->on("users"); + $table->foreign("event_id")->references("id")->on("events"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_events'); + } +} From b89c1509feb7f802e0cc39475621bf3b6ca14a9a Mon Sep 17 00:00:00 2001 From: Vedran Zelen <zelenvedran@gmail.com> Date: Tue, 28 Jul 2020 08:34:10 +0200 Subject: [PATCH 3/3] Added comments for easier understanding. --- .../migrations/2014_10_12_000000_create_users_table.php | 7 ++++++- .../2014_10_12_100000_create_password_resets_table.php | 2 ++ .../2019_08_19_000000_create_failed_jobs_table.php | 3 +++ .../2020_06_08_080402_create_permission_tables.php | 2 ++ .../2020_06_08_085447_create_washing_reservations.php | 2 ++ .../migrations/2020_06_08_090042_create_calendar_dates.php | 2 ++ .../2020_06_08_090108_create_calendar_events.php | 2 ++ .../migrations/2020_06_08_091617_create_feedbacks.php | 2 ++ .../2020_06_08_123954_create_washing_machines.php | 2 ++ .../migrations/2020_06_09_081037_alter_feedbacks.php | 2 ++ .../2020_06_09_081126_alter_washing_reservations.php | 2 ++ .../migrations/2020_06_23_070657_create_menu_plans.php | 2 ++ .../migrations/2020_06_24_064840_create_external_links.php | 2 ++ .../migrations/2020_06_29_065007_create_contact.php | 2 ++ .../migrations/2020_06_29_091545_create_events.php | 2 ++ .../migrations/2020_06_30_065154_create_albums_table.php | 2 ++ .../2020_07_01_061911_create_resource_category.php | 2 ++ .../2020_07_01_062112_create_resource_extension.php | 2 ++ .../migrations/2020_07_01_062544_create_resource.php | 2 ++ .../2020_07_01_064330_create_resource_categories.php | 2 ++ skolehjem/database/seeds/UserSeeder.php | 7 +++++-- 21 files changed, 50 insertions(+), 3 deletions(-) diff --git a/skolehjem/database/migrations/2014_10_12_000000_create_users_table.php b/skolehjem/database/migrations/2014_10_12_000000_create_users_table.php index 9760e02..ef119d6 100644 --- a/skolehjem/database/migrations/2014_10_12_000000_create_users_table.php +++ b/skolehjem/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -13,9 +15,10 @@ class CreateUsersTable extends Migration */ public function up() { + //checks if table already exists if(Schema::hasTable("users")) return; - + //if not, create a table with these fields Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name_first'); @@ -34,6 +37,8 @@ class CreateUsersTable extends Migration * * @return void */ + + //if table exists, drop table. public function down() { Schema::dropIfExists('users'); diff --git a/skolehjem/database/migrations/2014_10_12_100000_create_password_resets_table.php b/skolehjem/database/migrations/2014_10_12_100000_create_password_resets_table.php index 0ee0a36..5a8c158 100644 --- a/skolehjem/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/skolehjem/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/skolehjem/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 9bddee3..6b2cca4 100644 --- a/skolehjem/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/skolehjem/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -1,4 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema + +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; diff --git a/skolehjem/database/migrations/2020_06_08_080402_create_permission_tables.php b/skolehjem/database/migrations/2020_06_08_080402_create_permission_tables.php index 8e7ae7b..2ddad31 100644 --- a/skolehjem/database/migrations/2020_06_08_080402_create_permission_tables.php +++ b/skolehjem/database/migrations/2020_06_08_080402_create_permission_tables.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; diff --git a/skolehjem/database/migrations/2020_06_08_085447_create_washing_reservations.php b/skolehjem/database/migrations/2020_06_08_085447_create_washing_reservations.php index 482ddd7..3ac0a01 100644 --- a/skolehjem/database/migrations/2020_06_08_085447_create_washing_reservations.php +++ b/skolehjem/database/migrations/2020_06_08_085447_create_washing_reservations.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_08_090042_create_calendar_dates.php b/skolehjem/database/migrations/2020_06_08_090042_create_calendar_dates.php index 9106ec4..a6abe3b 100644 --- a/skolehjem/database/migrations/2020_06_08_090042_create_calendar_dates.php +++ b/skolehjem/database/migrations/2020_06_08_090042_create_calendar_dates.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_08_090108_create_calendar_events.php b/skolehjem/database/migrations/2020_06_08_090108_create_calendar_events.php index 95ca169..3750d0f 100644 --- a/skolehjem/database/migrations/2020_06_08_090108_create_calendar_events.php +++ b/skolehjem/database/migrations/2020_06_08_090108_create_calendar_events.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_08_091617_create_feedbacks.php b/skolehjem/database/migrations/2020_06_08_091617_create_feedbacks.php index c5700fa..676d6bb 100644 --- a/skolehjem/database/migrations/2020_06_08_091617_create_feedbacks.php +++ b/skolehjem/database/migrations/2020_06_08_091617_create_feedbacks.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_08_123954_create_washing_machines.php b/skolehjem/database/migrations/2020_06_08_123954_create_washing_machines.php index 7ef26d1..8b9ded4 100644 --- a/skolehjem/database/migrations/2020_06_08_123954_create_washing_machines.php +++ b/skolehjem/database/migrations/2020_06_08_123954_create_washing_machines.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_09_081037_alter_feedbacks.php b/skolehjem/database/migrations/2020_06_09_081037_alter_feedbacks.php index cf75b87..33e58f6 100644 --- a/skolehjem/database/migrations/2020_06_09_081037_alter_feedbacks.php +++ b/skolehjem/database/migrations/2020_06_09_081037_alter_feedbacks.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_09_081126_alter_washing_reservations.php b/skolehjem/database/migrations/2020_06_09_081126_alter_washing_reservations.php index 54cba2f..d39a3bb 100644 --- a/skolehjem/database/migrations/2020_06_09_081126_alter_washing_reservations.php +++ b/skolehjem/database/migrations/2020_06_09_081126_alter_washing_reservations.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php b/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php index e60532f..99e1b73 100644 --- a/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php +++ b/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_24_064840_create_external_links.php b/skolehjem/database/migrations/2020_06_24_064840_create_external_links.php index dc72ec1..b6da609 100644 --- a/skolehjem/database/migrations/2020_06_24_064840_create_external_links.php +++ b/skolehjem/database/migrations/2020_06_24_064840_create_external_links.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_29_065007_create_contact.php b/skolehjem/database/migrations/2020_06_29_065007_create_contact.php index 0c01880..9c79bc1 100644 --- a/skolehjem/database/migrations/2020_06_29_065007_create_contact.php +++ b/skolehjem/database/migrations/2020_06_29_065007_create_contact.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_29_091545_create_events.php b/skolehjem/database/migrations/2020_06_29_091545_create_events.php index 443aba9..a6433b1 100644 --- a/skolehjem/database/migrations/2020_06_29_091545_create_events.php +++ b/skolehjem/database/migrations/2020_06_29_091545_create_events.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_06_30_065154_create_albums_table.php b/skolehjem/database/migrations/2020_06_30_065154_create_albums_table.php index bfe0dab..bd5f02a 100644 --- a/skolehjem/database/migrations/2020_06_30_065154_create_albums_table.php +++ b/skolehjem/database/migrations/2020_06_30_065154_create_albums_table.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_07_01_061911_create_resource_category.php b/skolehjem/database/migrations/2020_07_01_061911_create_resource_category.php index 4d797bb..f929b10 100644 --- a/skolehjem/database/migrations/2020_07_01_061911_create_resource_category.php +++ b/skolehjem/database/migrations/2020_07_01_061911_create_resource_category.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_07_01_062112_create_resource_extension.php b/skolehjem/database/migrations/2020_07_01_062112_create_resource_extension.php index ddba508..da3fa6c 100644 --- a/skolehjem/database/migrations/2020_07_01_062112_create_resource_extension.php +++ b/skolehjem/database/migrations/2020_07_01_062112_create_resource_extension.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_07_01_062544_create_resource.php b/skolehjem/database/migrations/2020_07_01_062544_create_resource.php index 0176e1b..acdef5a 100644 --- a/skolehjem/database/migrations/2020_07_01_062544_create_resource.php +++ b/skolehjem/database/migrations/2020_07_01_062544_create_resource.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php b/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php index 290931b..ab8cf54 100644 --- a/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php +++ b/skolehjem/database/migrations/2020_07_01_064330_create_resource_categories.php @@ -1,5 +1,7 @@ <?php +//Migrations acts as a version control for the database allowing you to modify the app's database schema +//allows use of necessary libraries use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/skolehjem/database/seeds/UserSeeder.php b/skolehjem/database/seeds/UserSeeder.php index e723546..d86b174 100644 --- a/skolehjem/database/seeds/UserSeeder.php +++ b/skolehjem/database/seeds/UserSeeder.php @@ -28,7 +28,10 @@ class UserSeeder extends Seeder }*/ - + /** + * A user is created as the Admin with the below fields. + * Super User or Admin. Is allowed for all permission and is not to exist in final product release but purely for testing. + */ Log::debug("OPRET"); $user = new \App\User(); @@ -39,7 +42,7 @@ class UserSeeder extends Seeder $user->phone = 12345678; - + //gives all permission to the Admin. foreach (\Spatie\Permission\Models\Permission::all() as $permission) { $user->givePermissionTo($permission); }