This commit is contained in:
Sebastian Davaris 2020-07-28 10:22:56 +02:00
commit 22615b5f7d
33 changed files with 116 additions and 23 deletions

View File

@ -7,7 +7,7 @@ use Illuminate\Http\Response;
use App\Contact; use App\Contact;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Context;
//hello
class ContactController extends Controller class ContactController extends Controller
{ {
public function __construct() public function __construct()
@ -146,16 +146,16 @@ class ContactController 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/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>". "<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
"</tr>"; "</tr>";
$users = DB::table('contacts')->where('name_first', 'LIKE',$request->search.'%') $users = DB::table('contacts')->where('contactname', 'LIKE',$request->search.'%')
->orWhere('name_last','LIKE', $request->search.'%') ->orWhere('title','LIKE', $request->search.'%')
->orWhere('phone','LIKE', $request->search.'%') ->orWhere('phone','LIKE', $request->search.'%')
->orWhere('email','LIKE',$request->search. '%')->get(); ->orWhere('email','LIKE',$request->search. '%')->get();
if(count($users) !== 0){ if(count($users) !== 0){
foreach ($users as $key => $user){ foreach ($users as $key => $user){
$output.='<tr>'. $output.='<tr>'.
'<td>' . $user->name_first . '</td>'. '<td>' . $user->contactname . '</td>'.
'<td>' . $user->name_last . '</td>'. '<td>' . $user->title . '</td>'.
'<td>' . $user->email . '</td>'. '<td>' . $user->email . '</td>'.
'<td>' . $user->phone .'</td>'. '<td>' . $user->phone .'</td>'.
'<td><a href="'. route("contacts.edit", [ "contact" => $user->id ]) . '"><img class="w-100" src="'. asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>'. '<td><a href="'. route("contacts.edit", [ "contact" => $user->id ]) . '"><img class="w-100" src="'. asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>'.

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use App\UserEvent;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class UserEventController extends Controller
{
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function create(Request $request)
{
// Get written data from events.index
$data = $request->validate([
"user_id" => "required|max:255",
"event_id" => "required|max:255"
]);
// Check the UserEvent table if there is a row that has the user_id AND the event_id
$getTableInfo = UserEvent::where('user_id', $request->user_id)
->where('event_id', $request->event_id)->get();
// If the row has both, then go back and show an error - Cause you're not allowed to be on the same event twice.
if (count($getTableInfo) > 0)
return redirect()->route("events.index")->with('error#' . $request->event_id, '<p class="text-center">Du har allerede tilmeldt dig denne Aktivitet!</p>');
// If not, then it keeps going and saves and shows a success message
$UserEvent = new UserEvent($data);
$UserEvent->save();
return redirect()->route("events.index")->with('signup#' . $request->event_id, '<p class="text-center">Du er hermed tilmeldt denne aktivitet!</p>');
}
}

View File

@ -6,5 +6,13 @@ use Illuminate\Database\Eloquent\Model;
class UserEvent extends Model class UserEvent extends Model
{ {
// /**
* The attributes that are mass assignable.
*
* @var array
*/
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'user_id', 'event_id'
];
} }

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@ -13,9 +15,10 @@ class CreateUsersTable extends Migration
*/ */
public function up() public function up()
{ {
//checks if table already exists
if(Schema::hasTable("users")) if(Schema::hasTable("users"))
return; return;
//if not, create a table with these fields
Schema::create('users', function (Blueprint $table) { Schema::create('users', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name_first'); $table->string('name_first');
@ -34,6 +37,8 @@ class CreateUsersTable extends Migration
* *
* @return void * @return void
*/ */
//if table exists, drop table.
public function down() public function down()
{ {
Schema::dropIfExists('users'); Schema::dropIfExists('users');

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,4 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;

View File

@ -1,5 +1,7 @@
<?php <?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\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,7 @@
<?php <?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\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -15,8 +15,8 @@ class CreateUserEventsTable extends Migration
{ {
Schema::create('user_events', function (Blueprint $table) { Schema::create('user_events', function (Blueprint $table) {
$table->id(); $table->id();
$table->integer("user_id")->unique(); $table->integer("user_id");
$table->integer("event_id")->unique(); $table->integer("event_id");
$table->timestamps(); $table->timestamps();

View File

@ -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"); Log::debug("OPRET");
$user = new \App\User(); $user = new \App\User();
@ -39,7 +42,7 @@ class UserSeeder extends Seeder
$user->phone = 12345678; $user->phone = 12345678;
//gives all permission to the Admin.
foreach (\Spatie\Permission\Models\Permission::all() as $permission) { foreach (\Spatie\Permission\Models\Permission::all() as $permission) {
$user->givePermissionTo($permission); $user->givePermissionTo($permission);
} }

View File

@ -10,7 +10,6 @@
@endsection @endsection
@section("content") @section("content")
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<div class="row align-items-center"> <div class="row align-items-center">
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('contacts.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Kontakt</a> <a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('contacts.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Kontakt</a>

View File

@ -10,7 +10,6 @@
@endsection @endsection
@section("content") @section("content")
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<div class="row align-items-center"> <div class="row align-items-center">
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('events.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Event</a> <a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('events.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Event</a>

View File

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link type="text/css" rel="stylesheet" href="{{ mix("/css/admin.css") }}"> <link type="text/css" rel="stylesheet" href="{{ mix("/css/admin.css") }}">
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
</head> </head>
<body> <body>
@yield("header") @yield("header")
@ -31,9 +32,6 @@
<div class="segment"> <div class="segment">
<h3 class="text-white"><a href="{{ route("external-links.index") }}" class="text-white">Eksterne Links</a></h3> <h3 class="text-white"><a href="{{ route("external-links.index") }}" class="text-white">Eksterne Links</a></h3>
</div> </div>
{{-- <div class="segment">--}}
{{-- <h3 class="text-white"><a href="{{ route('staff.index') }}" class="text-white">Personale</a></h3>--}}
{{-- </div>--}}
<div class="segment"> <div class="segment">
<h3 class="text-white"><a href="{{ route("contacts.index") }}" class="text-white">Kontakter</a></h3> <h3 class="text-white"><a href="{{ route("contacts.index") }}" class="text-white">Kontakter</a></h3>
</div> </div>

View File

@ -10,7 +10,6 @@
@endsection @endsection
@section("content") @section("content")
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<div class="row align-items-center"> <div class="row align-items-center">
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('roles.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Rolle</a> <a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('roles.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Rolle</a>

View File

@ -10,7 +10,6 @@
@endsection @endsection
@section("content") @section("content")
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<div class="row align-items-center"> <div class="row align-items-center">

View File

@ -9,10 +9,16 @@
<h1 class="text-center sde-blue mb-0">Aktiviteter</h1> <h1 class="text-center sde-blue mb-0">Aktiviteter</h1>
@if(!$events->isEmpty()) @if(!$events->isEmpty())
@foreach($events as $event) @foreach($events as $event)
<form method="get" action="{{ route("userevents.create") }}">
<h3 class="sde-blue bold text-center mb-0">{{$event->name}}</h3> <h3 class="sde-blue bold text-center mb-0">{{$event->name}}</h3>
<p class="text-center mt-0">{{$event->date}}</p> <p class="text-center mt-0">{{$event->date}}</p>
<p class="text-center">{{$event->description}}</p> <p class="text-center">{{$event->description}}</p>
<a class="btn text-center btn-sde-blue" id="tilmeld">Tilmeld</a> <input type="hidden" name="user_id" value="{{ Auth::user()->id }}">
<input type="hidden" name="event_id" value="{{ $event->id }}">
{!! session()->get('error#' . $event->id) !!}
{!! session()->get('signup#' . $event->id) !!}
<button type="submit" class="btn text-center btn-sde-blue" id="tilmeld">Tilmeld</button>
</form>
@endforeach @endforeach
@else @else
<p class="text-center">Der er ingen aktiviteter!</p> <p class="text-center">Der er ingen aktiviteter!</p>

View File

@ -3,15 +3,12 @@
<head> <head>
<title>@yield("title")</title> <title>@yield("title")</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
{{-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">--}}
<link type="text/css" rel="stylesheet" href="{{ mix("/css/webapp.css") }}"> <link type="text/css" rel="stylesheet" href="{{ mix("/css/webapp.css") }}">
</head> </head>
<body> <body>
{{-- @yield("header")--}}
<header class="row align-items-center"> <header class="row align-items-center">
<img class="w-50" id="sdeLogo" src="{{URL::asset('/images/logos/Logo-normal.svg')}}" alt="Syddansk Erhvervsskole"> <img class="w-50" id="sdeLogo" src="{{URL::asset('/images/logos/Logo-normal.svg')}}" alt="Syddansk Erhvervsskole">
<button class="ml-auto" id="toggle"> <button class="ml-auto" id="toggle">
{{-- <img src="{{URL::asset('/images/icons/icon.svg')}}" id="menuIcon" alt="-">--}}
<i id="icon" class="fas fa-bars"></i> <i id="icon" class="fas fa-bars"></i>
</button> </button>
</header> </header>

View File

@ -42,8 +42,8 @@ Route::get("/userapi", "UserController@search")->name("users.search");
Route::resource("contacts", "ContactController"); Route::resource("contacts", "ContactController");
Route::resource("menu-plans", "MenuPlanController"); Route::resource("menu-plans", "MenuPlanController");
Route::resource("users", "UserController"); Route::resource("users", "UserController");
//Route::resource("staff", "StaffController");
Route::resource("events", "EventController"); Route::resource("events", "EventController");
Route::resource("userevents", "UserEventController");
Route::resource("washing-machines", "WashingMachineController"); Route::resource("washing-machines", "WashingMachineController");
Route::resource("washing-reservations", "WashingReservationController"); Route::resource("washing-reservations", "WashingReservationController");
Route::resource("feedbacks", "FeedbackController"); Route::resource("feedbacks", "FeedbackController");