Delete Users
This commit is contained in:
parent
4253194117
commit
ba11930641
5 changed files with 556 additions and 204 deletions
|
|
@ -3,7 +3,7 @@ APP_ENV=local
|
|||
APP_KEY=base64:7Md2wHHNq04ldtpdsz4B2LDAMEOB+4fSfxMJGfDU2zY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://test.motorrad-ig.de
|
||||
LOG_CHANNEL=stack
|
||||
LOG_CHANNEL=daily
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Log;
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
||||
|
|
@ -34,17 +36,17 @@ class UserController extends Controller
|
|||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
* /
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* public function store(Request $request)
|
||||
* {
|
||||
*
|
||||
* }
|
||||
*
|
||||
* /**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
|
|
@ -67,9 +69,15 @@ class UserController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
error_log("Edit:" . $id);
|
||||
$user = User::find($id);
|
||||
|
||||
if (Auth::user()->role != 'ADMIN' && $user->id != Auth::user()->id) {
|
||||
return redirect('/users');
|
||||
}
|
||||
|
||||
|
||||
error_log($user);
|
||||
return view('users.edit')->with('user', $user);
|
||||
}
|
||||
|
|
@ -134,11 +142,23 @@ class UserController extends Controller
|
|||
* @param \App\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(User $user)
|
||||
public function destroy($user_id)
|
||||
{
|
||||
//
|
||||
$user = User::find($user_id);
|
||||
Log::info("UserController::destroy for user_id " . $user->id);
|
||||
|
||||
Log::info("Preparing to destroy user [" . $user->id . "]" . $user->name);
|
||||
Log::info("#DESTROY_USER [users]" . $user);
|
||||
|
||||
$tours = DB::select("SELECT id FROM tours WHERE user_id=" . $user_id);
|
||||
Log::info('#DESTROY_USER [affected tour ids]', $tours);
|
||||
$bookings = DB::select("SELECT id FROM bookings WHERE user_id=" . $user_id);
|
||||
Log::info("#DESTROY_USER [affected booking ids]", $bookings);
|
||||
|
||||
DB::delete('DELETE FROM users WHERE id=' . $user->id);
|
||||
|
||||
return redirect('/member/');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,22 +4,27 @@
|
|||
<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="post" action="/member/{{$user->name}}" enctype="multipart/form-data">
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/member/{{$user->name}}"
|
||||
enctype="multipart/form-data">
|
||||
@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="{{ old('name') ?? $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="mobile" ><h4>Telefonnummer:</h4></label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="mobile" style="font-size:20px;" name="mobile" value="{{ old('mobile') ?? $user->mobile }}" required >
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="mobile"><h4>Telefonnummer:</h4>
|
||||
</label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="mobile" style="font-size:20px;" name="mobile"
|
||||
value="{{ old('mobile') ?? $user->mobile }}" 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="{{ old('email') ?? $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>
|
||||
|
||||
|
||||
|
|
@ -28,14 +33,17 @@
|
|||
|
||||
@if(file_exists (storage_path().'/img_storage/user/'.$user->id.'.jpg'))
|
||||
<!--File exists -->
|
||||
<a href="/img_storage/user/{{$user->id}}_gross.jpg" data-lightbox="{{$user->id}}_gross.jpg" data-title="{{ $user->name }}">
|
||||
<img src="/img_storage/user/{{$user->id}}.jpg" id="bild" class="mt-3 ml-3" style="width:256px;height:256px">
|
||||
<a href="/img_storage/user/{{$user->id}}_gross.jpg" data-lightbox="{{$user->id}}_gross.jpg"
|
||||
data-title="{{ $user->name }}">
|
||||
<img src="/img_storage/user/{{$user->id}}.jpg" id="bild" class="mt-3 ml-3"
|
||||
style="width:256px;height:256px">
|
||||
</a>
|
||||
@else
|
||||
<img src="/img/placeholder/user64x96.jpg" id="bild" class="mt-3 ml-3">
|
||||
@endif
|
||||
|
||||
<input type="file" class="mt-3 mr-2 form-control" style="font-size:20px;" name="bild" value="" accept="image/*" onchange="preview_image(event)">
|
||||
<input type="file" class="mt-3 mr-2 form-control" style="font-size:20px;" name="bild" value=""
|
||||
accept="image/*" onchange="preview_image(event)">
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -43,10 +51,18 @@
|
|||
<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 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
|
||||
|
|
@ -56,11 +72,14 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
<a href="/member" class="btn btn-primary col-2 mb-2 float-left" style="margin-right:20px;">Zurück</a>
|
||||
|
||||
@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>
|
||||
<a href="/admin/destroy_user/{{$user->id}}" class="btn btn-primary col-2 mb-2 float-left"
|
||||
style="margin-right:20px;">Löschen</a>
|
||||
@endif
|
||||
|
||||
<a href="/member" class="btn btn-primary col-2 mb-2 float-left">Zurück</a>
|
||||
|
||||
</form>
|
||||
|
||||
|
|
@ -69,12 +88,10 @@
|
|||
<!-------------------------------- ----------------------------->
|
||||
|
||||
<script>
|
||||
function preview_image(event)
|
||||
{
|
||||
function preview_image(event) {
|
||||
console.log("Preview triggered.")
|
||||
var reader = new FileReader();
|
||||
reader.onload = function()
|
||||
{
|
||||
reader.onload = function () {
|
||||
console.log("onload")
|
||||
var output = document.getElementById('bild');
|
||||
console.log(output);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,16 @@ Route::get('/home', 'PageController@page_home')->name('home');
|
|||
Route::post('/admin/store_home', 'AdminController@store_home')->middleware('auth');
|
||||
Route::get('/activities', 'PageController@page_activities');
|
||||
|
||||
Route::get('/become_member', function () { return view('users.become_member'); });
|
||||
Route::get('/meetings', function () { return view('meetings'); })->middleware('auth');
|
||||
Route::get('/become_member', function () {
|
||||
return view('users.become_member');
|
||||
});
|
||||
Route::get('/meetings', function () {
|
||||
return view('meetings');
|
||||
})->middleware('auth');
|
||||
|
||||
Route::resource('/member', UserController::class);
|
||||
|
||||
Route::get('/admin/destroy_user/{user_id}', 'UserController@destroy')->middleware('auth');
|
||||
Route::get('/admin/upload_tourplan', 'AdminController@upload_tourplan')->middleware('auth');
|
||||
Route::post('/admin/store_tourplan', 'AdminController@store_tourplan')->middleware('auth');
|
||||
|
||||
|
|
@ -61,5 +66,9 @@ Route::get('/img_storage/{category}/{imageName}','ImageController@getImage'); //
|
|||
Auth::routes();
|
||||
|
||||
/* Cache clearing on remote server */
|
||||
Route::get('/clear-cache', function() { Artisan::call('cache:clear');Artisan::call('config:clear'); return "Cache cleared, Config reloaded"; });
|
||||
Route::get('/clear-cache', function () {
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('config:clear');
|
||||
return "Cache cleared, Config reloaded";
|
||||
});
|
||||
//Route::get('/home', 'HomeController@index')->name('home');
|
||||
|
|
|
|||
306
tools/motorradig_2023-01-13_092650.sql
Normal file
306
tools/motorradig_2023-01-13_092650.sql
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue