update+save changed user(edit)
This commit is contained in:
parent
f7c6df6b87
commit
c96939773e
2 changed files with 25 additions and 9 deletions
|
|
@ -37,7 +37,7 @@ class UserController extends Controller
|
|||
* /
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +82,21 @@ class UserController extends Controller
|
|||
*/
|
||||
public function update(Request $request, User $user)
|
||||
{
|
||||
//
|
||||
$user=User::find($request->input('id'));
|
||||
|
||||
$request->validate(
|
||||
[
|
||||
'name'=>'required|min:3',
|
||||
'email'=>'required|email'
|
||||
]
|
||||
);
|
||||
|
||||
$user->name=$request->input('name');
|
||||
$user->email=$request->input('email');
|
||||
$user->save();
|
||||
|
||||
return redirect('/member/');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,17 +4,19 @@
|
|||
<div class="container text-center text-light mt-5">
|
||||
<h1 class="text-center">{{$user->name}}</h1>
|
||||
|
||||
<form style="background-color: #fff;" class="text-dark" method="GET" action="/member">
|
||||
{{ csrf_field() }}
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/member/{{$user->name}}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<input type="hidden" name="id" value="{{ $user->id }}">
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="name"><h4>Name:</h4></label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="name" style="font-size:20px;" name="name" value="{{ $user->name }}" required >
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="name" style="font-size:20px;" name="name" value="{{ old('name') ?? $user->name }}" required >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="name" ><h4>EMail:</h4></label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="lastname" style="font-size:20px;" name="email" value="{{ $user->email }}" required >
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="lastname" style="font-size:20px;" name="email" value="{{ old('email') ?? $user->email }}" required >
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -29,12 +31,12 @@
|
|||
</div>
|
||||
|
||||
@if(Auth::user()->role=="ADMIN")
|
||||
<a href="#" class="btn btn-danger col-2 mb-2 float-right mr-2">Speichern</a>
|
||||
<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">Abbrechen</a>
|
||||
<a href="/member" class="btn btn-primary col-2 mb-2 float-left">Zurück</a>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue