User Self-Edit

This commit is contained in:
TorstenS 2020-09-29 10:46:03 +02:00
parent 81a0b5d7ab
commit 66d7802f7a
3 changed files with 23 additions and 22 deletions

View file

@ -89,6 +89,7 @@ class UserController extends Controller
[
'name'=>'required|min:3',
'email'=>'required|email',
'role'=>'required',
'bild'=>'mimes:jpg,jpeg,bmp,png,gif'
]
);
@ -116,6 +117,7 @@ class UserController extends Controller
$user->name=$request->input('name');
$user->email=$request->input('email');
$user->role=$request->input('role');
$user->save();
return redirect('/member/');

View file

@ -32,22 +32,31 @@
<img src="/img/placeholder/user64x96.jpg" class="mt-3 ml-3" >
@endif
<input type="file" class="mt-3 mr-2 form-control" id="bild" style="font-size:20px;" name="bild" value="" required >
<input type="file" class="mt-3 mr-2 form-control" id="bild" style="font-size:20px;" name="bild" value="" >
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:130px; text-align:left;" for="name" ><h4>Rolle:</h4></label>
<select name="role" class="dropdown-item ml-3 border form-control mt-3 mr-2" style="font-size:18px;" selected="{{ old('role') ?? $user->role }}">
<option value="GUEST" style="font-size:18px;" class="dropdown-item bg-light form-control" {{ $user->role=="GUEST" ? "selected" : "" }} >GUEST</option>
<option value="MEMBER" style="font-size:18px;" class="dropdown-item bg-light" {{ $user->role=="MEMBER" ? "selected" : "" }} >MEMBER</option>
<option value="ADMIN" style="font-size:18px;" class="dropdown-item bg-light" {{ $user->role=="ADMIN" ? "selected" : "" }} >ADMIN</option>
</select>
</div>
@if(Auth::user()->role=="ADMIN")
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:130px; text-align:left;" for="name" ><h4>Rolle:</h4></label>
<select name="role" class="dropdown-item ml-3 border form-control mt-3 mr-2" style="font-size:18px;" selected="{{ old('role') ?? $user->role }}">
<option value="GUEST" style="font-size:18px;" class="dropdown-item bg-light form-control" {{ $user->role=="GUEST" ? "selected" : "" }} >GUEST</option>
<option value="MEMBER" style="font-size:18px;" class="dropdown-item bg-light" {{ $user->role=="MEMBER" ? "selected" : "" }} >MEMBER</option>
<option value="ADMIN" style="font-size:18px;" class="dropdown-item bg-light" {{ $user->role=="ADMIN" ? "selected" : "" }} >ADMIN</option>
</select>
</div>
@else
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:130px; text-align:left;" for="name" ><h4>Rolle:</h4></label>
<h4 class="mt-4">{{$user->role}}</h4>
</div>
@endif
@if(Auth::user()->role=="ADMIN" || Auth::user()->id==$user->id)
<button type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Speichern</button>
@endif
<a href="/member" class="btn btn-primary col-2 mb-2 float-left">Zurück</a>
</form>

View file

@ -35,20 +35,10 @@
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:130px; text-align:left;" for="name" ><h4>Rolle:</h4></label>
<div class="dropdown mt-3">
<button class="btn btn-secondary dropdown-toggle bg-light text-dark" type="button" id="dropdownMenuButton" data-toggle="" aria-haspopup="true" aria-expanded="false">
{{$user->role}}
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">GUEST</a>
<a class="dropdown-item" href="#">MEMBER</a>
<a class="dropdown-item" href="#">ADMIN</a>
</div>
</div>
<h4 class="mt-4">{{$user->role}}</h4>
</div>
@if(Auth::user()->role=="ADMIN")
@if(Auth::user()->role=="ADMIN" || Auth::user()->id==$user->id)
<a href="/member/{{$user->id}}/edit" class="btn btn-danger col-2 mb-2 float-right mr-2">Bearbeiten</a>
@endif
<a href="/member" class="btn btn-primary col-2 mb-2 float-left">Zurück</a>