diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..3cb0860 --- /dev/null +++ b/.env.production @@ -0,0 +1,43 @@ +APP_NAME="WIT-TEST-Shop" +APP_ENV=production +APP_KEY= +APP_DEBUG=false +APP_URL=https://witstore.wende.it + +APP_LOCALE=de +APP_FALLBACK_LOCALE=de +APP_FAKER_LOCALE=de_DE + +BCRYPT_ROUNDS=12 + +LOG_CHANNEL=stack +LOG_LEVEL=error + +DB_CONNECTION=mysql +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=wendeIT_WITS +DB_USERNAME=wendeIT_WITSU +DB_PASSWORD=Sfn4r3z3U?krhzM? + +SESSION_DRIVER=file +SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null + +FILESYSTEM_DISK=public +QUEUE_CONNECTION=database + +CACHE_STORE=file + +MAIL_MAILER=smtp +MAIL_SCHEME=tls +MAIL_HOST=smtp.wende.it +MAIL_PORT=587 +MAIL_USERNAME=shop@wende.it +MAIL_PASSWORD= +MAIL_FROM_ADDRESS="shop@wende.it" +MAIL_FROM_NAME="WIT-TEST-Shop" + +VITE_APP_NAME="${APP_NAME}" diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php new file mode 100644 index 0000000..39896f7 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -0,0 +1,82 @@ +orderBy('name')->get(); + return view('admin.admins.index', compact('admins')); + } + + public function create() + { + return view('admin.admins.form', ['admin' => null]); + } + + public function store(Request $request) + { + $data = $request->validate([ + 'name' => 'required|string|max:255', + 'email' => 'required|email|unique:users,email', + 'role' => 'required|in:admin,super_admin', + 'password' => 'required|min:8|confirmed', + ]); + + User::create([ + 'name' => $data['name'], + 'email' => $data['email'], + 'role' => $data['role'], + 'password' => Hash::make($data['password']), + 'approved' => true, + 'email_verified_at' => now(), + ]); + + return redirect()->route('admin.admins.index')->with('success', 'Admin-Benutzer angelegt.'); + } + + public function edit(User $admin) + { + abort_if(! $admin->isAdmin(), 404); + return view('admin.admins.form', compact('admin')); + } + + public function update(Request $request, User $admin) + { + abort_if(! $admin->isAdmin(), 404); + + $data = $request->validate([ + 'name' => 'required|string|max:255', + 'email' => 'required|email|unique:users,email,' . $admin->id, + 'role' => 'required|in:admin,super_admin', + 'password' => 'nullable|min:8|confirmed', + ]); + + $admin->name = $data['name']; + $admin->email = $data['email']; + $admin->role = $data['role']; + + if (!empty($data['password'])) { + $admin->password = Hash::make($data['password']); + } + + $admin->save(); + + return redirect()->route('admin.admins.index')->with('success', 'Admin-Benutzer aktualisiert.'); + } + + public function destroy(User $admin) + { + abort_if(! $admin->isAdmin(), 404); + abort_if($admin->id === auth()->id(), 403, 'Sie können sich nicht selbst löschen.'); + + $admin->delete(); + return back()->with('success', 'Admin-Benutzer gelöscht.'); + } +} diff --git a/resources/views/admin/admins/form.blade.php b/resources/views/admin/admins/form.blade.php new file mode 100644 index 0000000..5e31d88 --- /dev/null +++ b/resources/views/admin/admins/form.blade.php @@ -0,0 +1,60 @@ +@extends('layouts.admin') +@section('title', $admin ? 'Admin bearbeiten' : 'Neuer Admin') +@section('content') +
| Name | +Rolle | +Erstellt | ++ | |
|---|---|---|---|---|
| + {{ $a->name }} + @if($a->id === auth()->id()) (Sie) @endif + | +{{ $a->email }} | ++ @if($a->role === 'super_admin') + Super-Admin + @else + Admin + @endif + | +{{ $a->created_at->format('d.m.Y') }} | ++ Bearbeiten + @if($a->id !== auth()->id()) + + @endif + | +