This commit is contained in:
Sebastian Davaris 2020-07-01 08:14:34 +02:00
commit 903341c1ec
25 changed files with 83 additions and 216 deletions

View File

@ -154,6 +154,13 @@ class UserController extends Controller
/** @var User $user */
$user->update($data);
$user->roles()->detach();
$user->forgetCachedPermissions();
foreach ($request->roles as $role){
$user->assignRole($role);
}
$user->save();
// }
@ -231,5 +238,13 @@ class UserController extends Controller
return redirect()->route('users.login');
}
public function account()
{
return Response::detect("users.account");
}
public function accountedit()
{
return Response::detect("users.edit");
}
}

View File

@ -21,7 +21,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name_first', "name_last", 'email', 'password', "phone", "roles"
'name_first', "name_last", 'email', 'password', "phone"
];
/**

View File

@ -30,7 +30,7 @@
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -28,7 +28,7 @@
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -26,7 +26,7 @@
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -32,7 +32,7 @@
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -26,7 +26,7 @@
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -1,30 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Opret
@endsection
@section("path")
<a href="{{ route('staff.create') }}" class="text-white">Opret Personal</a> /
@endsection
@section("content")
<h1>Opret Personal:</h1>
<form method="post" action="{{ route("staff.store") }}">
@csrf
<label for="name_first">Fornavn:</label>
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" required>
<label for="name_last">Efternavn:</label>
<input type="text" name="name_last" id="name_last" placeholder="Efternavn" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="x@y.z" required>
<label for="password1">Password:</label>
<input type="password" name="password" placeholder="Password" id="password1" required>
<label for="password2">Bekræft Password:</label>
<input type="password" id="password2" placeholder="Bekræft Password" required>
<label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" placeholder="12345678" pattern="[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" required>
<input type="submit" class="btn btn-dark text-white" value="Opret">
</form>
@endsection

View File

@ -1,13 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Fjern
@endsection
@section("path")
<a href="{{ route('staff.delete') }}" class="text-white">Fjern Personal</a> /
@endsection
@section("content")
@endsection

View File

@ -1,31 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Rediger
@endsection
@section("path")
<a href="{{ route('staff.edit', ['staff' => $staff]) }}" class="text-white">Rediger Personal</a> /
@endsection
@section("content")
<h1>Rediger Personal:</h1>
<form method="post" action="{{ route("staff.update", ['staff' => $staff]) }}">
@csrf
@method("put")
<label for="name_first">Fornavn:</label>
<input type="text" name="name_first" id="name_first" value="{{ $staff->name_first }}" required>
<label for="name_last">Efternavn:</label>
<input type="text" name="name_last" id="name_last" value="{{ $staff->name_last }}" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" value="{{ $staff->email }}" required>
<label for="password1">Password:</label>
<input type="password" name="password" id="password1" value="" required>
<label for="password2">Confirm Password:</label>
<input type="password" id="password2" value="" required>
<label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" value="{{ $staff->phone }}" required>
<input type="submit" class="btn btn-dark text-white" value="Rediger">
</form>
@endsection

View File

@ -1,41 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Vis
@endsection
@section("path")
<a href="{{ route('staff.index') }}" class="text-white">Vis Personal</a> /
@endsection
@section("content")
<table class="tbl">
<tr>
<th>Fornavn</th>
<th>Efternavn</th>
<th>Email</th>
<th>Tlf nr</th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
</tr>
@foreach($staffs as $staff)
<tr>
<td>{{ $staff->name_first }}</td>
<td>{{ $staff->name_last }}</td>
<td>{{ $staff->email }}</td>
<td>{{ $staff->phone }}</td>
<td><a href="{{ route("staff.edit", [ "staff" => $staff->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><form method="post" action="{{ route("staff.destroy", [ "staff" => $staff->id ]) }}" class="w-100 nostyle">
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>
@endforeach
</table>
{{ $staffs->links() }}
@endsection

View File

@ -1,27 +0,0 @@
@extends("app.layout.base")
@section("title")
Login
@endsection
@section("content")
<main style="background-color: #00788a; height: 100%;">
<div class="brand">
<img src="{{URL::asset('/images/logos/Logo-hvid.svg')}}" alt="Syddansk Erhvervsskole">
</div>
<form action="" method="post">
@csrf
<input class="appinput" type="email" name="email" placeholder="Email" required>
<input class="appinput" type="password" name="password" placeholder="Password" required>
<label class="toggle">
<input class="toggle__input" type="checkbox" name="rememberpassword">
<span class="toggle__label">
<span class="toggle__text text-white">Remember password</span>
</span>
</label>
<input class="btn btn-dark" type="submit" value="Sign in">
<button class="btn" onclick="window.location = '';">Sign up</button>
</form>
<a class="text-white text-center" href="">Forgot password?</a>
</main>
@endsection

View File

@ -1,14 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Home - Logud
@endsection
@section("path")
<a href="{{ route('staff.logout') }}" class="text-white">Logud</a> /
@endsection
@section("content")
@endsection

View File

@ -1,14 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Vis
@endsection
@section("path")
<a href="{{ route('staff.index') }}" class="text-white">Vis Personal</a> /
@endsection
@section("content")
show.blade.php
@endsection

View File

@ -1,14 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Opret
@endsection
@section("path")
<a href="{{ route('staff.create') }}" class="text-white">Opret Personal</a> /
@endsection
@section("content")
Personal blev (ikke) oprettet.
@endsection

View File

@ -1,14 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Personal - Rediger
@endsection
@section("path")
<a href="{{ route('staff.edit') }}" class="text-white">Rediger Personal</a> /
@endsection
@section("content")
Din Personal blev (ikke) redigeret.
@endsection

View File

@ -25,9 +25,9 @@
<input type="password" id="password2" placeholder="Bekræft Password" required>
<label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" placeholder="12345678" pattern="[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" required>
<label for="role">Rolle:</label>
<select name="role" id="role" class="mb-2" required>
<option disabled selected value> -- Vælg en Rolle -- </option>
<label for="roles">Rolle:</label>
<select name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
<option disabled selected value> -- Vælg Rolle(r) -- </option>
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach

View File

@ -27,8 +27,8 @@
<label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required>
<label for="role">Rolle:</label>
<select name="role" id="role" class="mb-2" required>
<option disabled selected value> -- Vælg en Rolle -- </option>
<select name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
<option disabled selected value> -- Vælg Rolle(r) -- </option>
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach

View File

@ -16,7 +16,7 @@
<th>Efternavn</th>
<th>Email</th>
<th>Tlf nr</th>
<th>Rolle</th>
<th>Rolle(r)</th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
</tr>
@ -26,13 +26,21 @@
<td>{{ $user->name_last }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->phone }}</td>
<td>{{ $user->roles }}</td>
<td>
@for($i = 0; $i < count($user->roles); $i++)
@if(count($user->roles)-1 != $i)
{{$user->roles[$i]->name}},
@else
{{$user->roles[$i]->name}}
@endif
@endfor
</td>
<td><a href="{{ route("users.edit", [ "user" => $user->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><form method="post" action="{{ route("users.destroy", [ "user" => $user ]) }}" class="w-100 nostyle">
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -20,7 +20,13 @@
<tr>
<td>{Navn}</td>
<td><a href=""><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><a href=""><img class="w-100" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a></td>
<td><form method="post" action="{{ route("washing-machines.destroy", [ "machine" => $machine ]) }}" class="w-100 nostyle">
@csrf
@method("delete")
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>
@endforeach
</table>

View File

@ -30,7 +30,7 @@
@csrf
@method("delete")
<button class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>

View File

@ -45,7 +45,7 @@
<img src="{{URL::asset('/images/icons/Vagttelefon-hvid.svg')}}" alt="Vagttelefon">
Vagttelefon
</a>
<a href="#">
<a href="{{ route("users.account") }}">
<img src="{{URL::asset('/images/icons/user-hvid.svg')}}" alt="Konto">
Konto
</a>

View File

@ -0,0 +1,15 @@
@extends("app.layout.base")
@section("title")
Account
@endsection
@section("content")
<main>
<h1 class="text-center sde-blue mt-0">Konto</h1>
<h4 class="mt-0">Navn: {{ Auth::user()->name_first . " " . Auth::user()->name_last }}</h4>
<h4 class="mt-0">Email: {{ Auth::user()->email }}</h4>
<h4 class="mt-0">Telefon Nr.: {{ Auth::user()->phone }}</h4>
<a class="btn text-center btn-sde-blue mt-1" href="{{ route("users.accountedit") }}">Rediger Oplysninger</a>
</main>
@endsection

View File

@ -0,0 +1,20 @@
@extends("app.layout.base")
@section("title")
Account
@endsection
@section("content")
<main>
<h1 class="text-center sde-blue mt-0">Konto</h1>
<form action="">
<span>Navn:</span>
<input type="text" name="name" id="name" value="{{ Auth::user()->name_first . " " . Auth::user()->name_last }}" disabled>
<span>Email:</span>
<input type="email" name="email" id="email" value="{{ Auth::user()->email }}" required>
<span>Telefon Nr.:</span>
<input type="text" name="phone" id="phone" value="{{ Auth::user()->phone }}" required>
<button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>
</form>
</main>
@endsection

View File

@ -25,7 +25,8 @@ Route::post("/login", "UserController@login")->name("users.login");
Route::get("/logout", "UserController@logout")->name("users.logout");
Route::get("/forgot", "UserController@showForgot")->name("users.show-forgot");
Route::post("/forgot", "UserController@forgot")->name("users.forgot");
Route::get("/account", "UserController@account")->name("users.account");
Route::get("/account/edit", "UserController@accountedit")->name("users.accountedit");
Route::get("phones", "PhoneController@index")->name("phones.index");