diff --git a/skolehjem/app/Http/Controllers/AlbumController.php b/skolehjem/app/Http/Controllers/AlbumController.php index 840daf7..191d47b 100644 --- a/skolehjem/app/Http/Controllers/AlbumController.php +++ b/skolehjem/app/Http/Controllers/AlbumController.php @@ -2,9 +2,84 @@ namespace App\Http\Controllers; +use App\Album; use Illuminate\Http\Request; class AlbumController extends Controller { - // + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + // + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + * + * @param \App\Album $album + * @return \Illuminate\Http\Response + */ + public function show(Album $album) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Album $album + * @return \Illuminate\Http\Response + */ + public function edit(Album $album) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Album $album + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Album $album) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Album $album + * @return \Illuminate\Http\Response + */ + public function destroy(Album $album) + { + // + } } diff --git a/skolehjem/app/Http/Controllers/ExternalLinkController.php b/skolehjem/app/Http/Controllers/ExternalLinkController.php index 2a6eafa..8f99398 100644 --- a/skolehjem/app/Http/Controllers/ExternalLinkController.php +++ b/skolehjem/app/Http/Controllers/ExternalLinkController.php @@ -9,6 +9,15 @@ use Illuminate\Http\Response; class ExternalLinkController extends Controller { + function __construct() + { + $this->middleware("permission:link.external.list")->only("index"); + $this->middleware("permission:link.external.create")->only(["create", "store"]); + $this->middleware("permission:link.external.show")->only("show"); + $this->middleware("permission:link.external.edit")->only(["edit", "update"]); + $this->middleware("permission:link.external.delete")->only("destroy"); + } + /** * Display a listing of the resource. * diff --git a/skolehjem/app/Http/Controllers/ImageController.php b/skolehjem/app/Http/Controllers/ImageController.php index 820ed55..4aeb7c8 100644 --- a/skolehjem/app/Http/Controllers/ImageController.php +++ b/skolehjem/app/Http/Controllers/ImageController.php @@ -2,9 +2,84 @@ namespace App\Http\Controllers; +use App\Image; use Illuminate\Http\Request; class ImageController extends Controller { - // + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + // + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + * + * @param \App\Image $image + * @return \Illuminate\Http\Response + */ + public function show(Image $image) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Image $image + * @return \Illuminate\Http\Response + */ + public function edit(Image $image) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Image $image + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Image $image) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Image $image + * @return \Illuminate\Http\Response + */ + public function destroy(Image $image) + { + // + } } diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index 78a6be3..ac5c34d 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -14,13 +14,14 @@ class UserController extends Controller { public function __construct() { -// $this->middleware([ "auth" ])->only("logout"); -// $this->middleware([ "guest" ])->only("login"); -// -// $this->middleware([ "permission:user.list", "role:admin" ])->only("index"); -// $this->middleware([ "permission:user.show", "role:admin" ])->only("show"); -// $this->middleware([ "permission:user.edit", "role:admin" ])->only([ "edit", "update" ]); -// $this->middleware([ "permission:user.delete", "role:admin" ])->only("delete"); + $this->middleware([ "auth" ])->only("logout"); + $this->middleware([ "guest" ])->only("login"); + + $this->middleware([ "check.auth:user.list" ])->only("index"); + $this->middleware([ "check.auth:user.show" ])->only("show"); + $this->middleware([ "check.auth:user.create" ])->only("create"); + $this->middleware([ "check.auth:user.edit" ])->only("edit", "update"); + $this->middleware([ "check.auth:user.delete" ])->only("delete"); } /** @@ -54,7 +55,7 @@ class UserController extends Controller */ public function store(Request $request) { - Log::debug("STORE FUNCTION"); +// Log::debug("STORE FUNCTION"); $data = $request->validate([ "name_first" => "required|max:255", @@ -65,15 +66,15 @@ class UserController extends Controller ]); - Log::debug("FINISHED VALIDATION?"); +// Log::debug("FINISHED VALIDATION?"); $user = new User($data); - Log::debug("CREATED USER [NOT PERSISTED YET]"); +// Log::debug("CREATED USER [NOT PERSISTED YET]"); $user->save(); - Log::debug("SAVED USER"); +// Log::debug("SAVED USER"); return Response::detect("users.store"); } @@ -182,7 +183,7 @@ class UserController extends Controller /*******************************************/ public function showLogin() { - return view("admin.users.login"); + return Response::detect("users.login"); } public function login(Request $request) { @@ -190,7 +191,7 @@ class UserController extends Controller if(Auth::attempt($data)) { //TODO: Implement home? - return redirect()->route("users.index"); + return redirect()->route("root.index"); } return redirect()->back(303); @@ -199,6 +200,6 @@ class UserController extends Controller public function logout(Request $request) { Auth::logout(); - return redirect()->to("/"); + return redirect()->route("root.index"); } } diff --git a/skolehjem/app/Http/Controllers/VideoController.php b/skolehjem/app/Http/Controllers/VideoController.php index b760852..486395e 100644 --- a/skolehjem/app/Http/Controllers/VideoController.php +++ b/skolehjem/app/Http/Controllers/VideoController.php @@ -2,9 +2,84 @@ namespace App\Http\Controllers; +use App\Video; use Illuminate\Http\Request; class VideoController extends Controller { - // + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + // + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + * + * @param \App\Video $video + * @return \Illuminate\Http\Response + */ + public function show(Video $video) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Video $video + * @return \Illuminate\Http\Response + */ + public function edit(Video $video) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Video $video + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Video $video) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Video $video + * @return \Illuminate\Http\Response + */ + public function destroy(Video $video) + { + // + } } diff --git a/skolehjem/app/Http/Kernel.php b/skolehjem/app/Http/Kernel.php index 6a08dd6..3e1e21b 100644 --- a/skolehjem/app/Http/Kernel.php +++ b/skolehjem/app/Http/Kernel.php @@ -67,5 +67,7 @@ class Kernel extends HttpKernel 'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class, 'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class, 'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class, + + "check.auth" => \App\Http\Middleware\CheckAuth::class ]; } diff --git a/skolehjem/app/MenuPlan.php b/skolehjem/app/MenuPlan.php index cce1492..c8131e1 100644 --- a/skolehjem/app/MenuPlan.php +++ b/skolehjem/app/MenuPlan.php @@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model; class MenuPlan extends Model { protected $fillable = [ - 'monday', "tuesday", 'wednesday', 'thursday', "friday", "saturday", "sunday" + 'monday', "tuesday", 'wednesday', 'thursday' ]; } 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 04e336e..9760e02 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 @@ -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'); 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 81d91b2..8e7ae7b 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 @@ -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'); diff --git a/skolehjem/database/migrations/2020_06_29_112658_create_staff_table.php b/skolehjem/database/migrations/2020_06_29_112658_create_staff_table.php deleted file mode 100644 index 0ad0194..0000000 --- a/skolehjem/database/migrations/2020_06_29_112658_create_staff_table.php +++ /dev/null @@ -1,38 +0,0 @@ -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'); - } -} diff --git a/skolehjem/database/migrations/2020_06_30_064605_create_gallery_album.php b/skolehjem/database/migrations/2020_06_30_064605_create_gallery_album.php deleted file mode 100644 index 64ef7bb..0000000 --- a/skolehjem/database/migrations/2020_06_30_064605_create_gallery_album.php +++ /dev/null @@ -1,31 +0,0 @@ -id(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('gallery_album'); - } -} diff --git a/skolehjem/database/migrations/2020_06_30_064640_create_gallery_video.php b/skolehjem/database/migrations/2020_06_30_064640_create_gallery_video.php deleted file mode 100644 index 47e1419..0000000 --- a/skolehjem/database/migrations/2020_06_30_064640_create_gallery_video.php +++ /dev/null @@ -1,31 +0,0 @@ -id(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('gallery_video'); - } -} diff --git a/skolehjem/database/migrations/2020_06_30_064737_create_gallery_image.php b/skolehjem/database/migrations/2020_06_30_064737_create_gallery_image.php deleted file mode 100644 index ad0d012..0000000 --- a/skolehjem/database/migrations/2020_06_30_064737_create_gallery_image.php +++ /dev/null @@ -1,31 +0,0 @@ -id(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('gallery_image'); - } -} diff --git a/skolehjem/database/seeds/DatabaseSeeder.php b/skolehjem/database/seeds/DatabaseSeeder.php index 64479c8..624abbb 100644 --- a/skolehjem/database/seeds/DatabaseSeeder.php +++ b/skolehjem/database/seeds/DatabaseSeeder.php @@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder public function run() { $this->call(PermissionSeeder::class); + $this->call(UserSeeder::class); } } diff --git a/skolehjem/database/seeds/PermissionSeeder.php b/skolehjem/database/seeds/PermissionSeeder.php index bbd8c28..8e2a639 100644 --- a/skolehjem/database/seeds/PermissionSeeder.php +++ b/skolehjem/database/seeds/PermissionSeeder.php @@ -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(); + } } } } diff --git a/skolehjem/resources/js/calendar/calendar.js b/skolehjem/resources/js/calendar/calendar.js index b7faff0..3af9468 100644 --- a/skolehjem/resources/js/calendar/calendar.js +++ b/skolehjem/resources/js/calendar/calendar.js @@ -93,6 +93,7 @@ function generateCalendar(weekOffset = 0) { function onDateSelect(date) { let events; let machinez; + let buttonz; let container = document.getElementById("event-container"); @@ -129,6 +130,23 @@ function onDateSelect(date) { events = document.getElementById("events"); } + if(document.getElementById("create-reservation") != undefined) + buttonz = document.getElementById("create-reservation"); + else { + // let span = document.createElement("span"); + // span.classList.add("events__title"); + // span.innerText = "Tider"; + + let button = document.createElement("button"); + // button.classList.add("events__title"); + button.id = "create-reservation"; + button.innerText = "Reserver"; + + // container.appendChild(span); + container.appendChild(button); + + buttonz = document.getElementById("events"); + } // events.innerHTML = ""; diff --git a/skolehjem/resources/views/admin/external-links/index.blade.php b/skolehjem/resources/views/admin/external-links/index.blade.php index 88be850..e9f726b 100644 --- a/skolehjem/resources/views/admin/external-links/index.blade.php +++ b/skolehjem/resources/views/admin/external-links/index.blade.php @@ -19,8 +19,8 @@ @foreach($links as $link) - {{$link->name}} - {{$link->link}} + {{$link->name}} + {{$link->link}} $link ]) }}">Update
$link ]) }}" class="w-100 nostyle"> @csrf diff --git a/skolehjem/resources/views/admin/layout/base.blade.php b/skolehjem/resources/views/admin/layout/base.blade.php index bb2b8c3..616e97a 100644 --- a/skolehjem/resources/views/admin/layout/base.blade.php +++ b/skolehjem/resources/views/admin/layout/base.blade.php @@ -50,23 +50,23 @@
-

Kontakter

+

Eksterne Links

-
-
-

Personale

- -
+{{--
--}} +{{--

Personale

--}} +{{--
--}} +{{-- ReadVis Personale--}} +{{--
--}} +{{--
--}} +{{-- CreateOpret Personal--}} +{{--
--}} +{{--
--}}

Feedback

diff --git a/skolehjem/resources/views/app/layout/base.blade.php b/skolehjem/resources/views/app/layout/base.blade.php index 50fb89c..18a4713 100644 --- a/skolehjem/resources/views/app/layout/base.blade.php +++ b/skolehjem/resources/views/app/layout/base.blade.php @@ -16,6 +16,10 @@