Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp
This commit is contained in:
commit
22615b5f7d
|
@ -7,7 +7,7 @@ use Illuminate\Http\Response;
|
|||
use App\Contact;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
//hello
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
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/trashcan.svg\" alt=\"Delete\"></th>".
|
||||
"</tr>";
|
||||
$users = DB::table('contacts')->where('name_first', 'LIKE',$request->search.'%')
|
||||
->orWhere('name_last','LIKE', $request->search.'%')
|
||||
$users = DB::table('contacts')->where('contactname', 'LIKE',$request->search.'%')
|
||||
->orWhere('title','LIKE', $request->search.'%')
|
||||
->orWhere('phone','LIKE', $request->search.'%')
|
||||
->orWhere('email','LIKE',$request->search. '%')->get();
|
||||
|
||||
if(count($users) !== 0){
|
||||
foreach ($users as $key => $user){
|
||||
$output.='<tr>'.
|
||||
'<td>' . $user->name_first . '</td>'.
|
||||
'<td>' . $user->name_last . '</td>'.
|
||||
'<td>' . $user->contactname . '</td>'.
|
||||
'<td>' . $user->title . '</td>'.
|
||||
'<td>' . $user->email . '</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>'.
|
||||
|
|
|
@ -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>');
|
||||
}
|
||||
}
|
|
@ -6,5 +6,13 @@ use Illuminate\Database\Eloquent\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'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -15,8 +15,8 @@ class CreateUserEventsTable extends Migration
|
|||
{
|
||||
Schema::create('user_events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer("user_id")->unique();
|
||||
$table->integer("event_id")->unique();
|
||||
$table->integer("user_id");
|
||||
$table->integer("event_id");
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
@endsection
|
||||
|
||||
@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">
|
||||
<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>
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
@endsection
|
||||
|
||||
@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">
|
||||
<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>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<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/admin.css") }}">
|
||||
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
@yield("header")
|
||||
|
@ -31,9 +32,6 @@
|
|||
<div class="segment">
|
||||
<h3 class="text-white"><a href="{{ route("external-links.index") }}" class="text-white">Eksterne Links</a></h3>
|
||||
</div>
|
||||
{{-- <div class="segment">--}}
|
||||
{{-- <h3 class="text-white"><a href="{{ route('staff.index') }}" class="text-white">Personale</a></h3>--}}
|
||||
{{-- </div>--}}
|
||||
<div class="segment">
|
||||
<h3 class="text-white"><a href="{{ route("contacts.index") }}" class="text-white">Kontakter</a></h3>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
@endsection
|
||||
|
||||
@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">
|
||||
<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>
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
@endsection
|
||||
|
||||
@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">
|
||||
|
||||
|
||||
|
|
|
@ -9,10 +9,16 @@
|
|||
<h1 class="text-center sde-blue mb-0">Aktiviteter</h1>
|
||||
@if(!$events->isEmpty())
|
||||
@foreach($events as $event)
|
||||
<form method="get" action="{{ route("userevents.create") }}">
|
||||
<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">{{$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
|
||||
@else
|
||||
<p class="text-center">Der er ingen aktiviteter!</p>
|
||||
|
|
|
@ -3,15 +3,12 @@
|
|||
<head>
|
||||
<title>@yield("title")</title>
|
||||
<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") }}">
|
||||
</head>
|
||||
<body>
|
||||
{{-- @yield("header")--}}
|
||||
<header class="row align-items-center">
|
||||
<img class="w-50" id="sdeLogo" src="{{URL::asset('/images/logos/Logo-normal.svg')}}" alt="Syddansk Erhvervsskole">
|
||||
<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>
|
||||
</button>
|
||||
</header>
|
||||
|
|
|
@ -42,8 +42,8 @@ Route::get("/userapi", "UserController@search")->name("users.search");
|
|||
Route::resource("contacts", "ContactController");
|
||||
Route::resource("menu-plans", "MenuPlanController");
|
||||
Route::resource("users", "UserController");
|
||||
//Route::resource("staff", "StaffController");
|
||||
Route::resource("events", "EventController");
|
||||
Route::resource("userevents", "UserEventController");
|
||||
Route::resource("washing-machines", "WashingMachineController");
|
||||
Route::resource("washing-reservations", "WashingReservationController");
|
||||
Route::resource("feedbacks", "FeedbackController");
|
||||
|
|
Loading…
Reference in New Issue