diff --git a/.gitignore b/.gitignore index 4bbe4c0..bcd4091 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /public/storage /public/reference /public/assets/images/references +/public/assets/images/members /storage/*.key /vendor .env diff --git a/app/Http/Controllers/DenController.php b/app/Http/Controllers/DenController.php index a15b3e9..ce9c672 100644 --- a/app/Http/Controllers/DenController.php +++ b/app/Http/Controllers/DenController.php @@ -37,10 +37,20 @@ class DenController extends Controller public function profile(Request $request) { $member = Auth::user(); + $avi = ''; + if ($member->avatar == 'default-member-avatar') { + $avi = '/assets/images/global/default-avi.png'; + } else { + $avi = $member->avatar; + } return view('back.profile', [ - 'handle' => $member->handle, - 'title' => "Your Profile", - 'role' => $member->role + 'title' => "Your Profile", + 'handle' => $member->handle, + 'email' => $member->email, + 'avatar' => $avi, + 'pronouns' => $member->pronoun, + 'uuid' => $member->uuid, + 'role' => $member->role ]); } diff --git a/app/Http/Controllers/MemberController.php b/app/Http/Controllers/MemberController.php new file mode 100644 index 0000000..c685b71 --- /dev/null +++ b/app/Http/Controllers/MemberController.php @@ -0,0 +1,28 @@ +members = $memberRepo; + } + + public function memberEdit(Request $request) + { + $token = csrf_token(); + $response = $this->members->edit($request); + if ($response['status'] == true) { + return back()->with('message', $response['message']); + } else { + return back()->withErrors([$response['message']]); + } + } +} diff --git a/app/Models/Member.php b/app/Models/Member.php index 21fdee4..f4397d6 100644 --- a/app/Models/Member.php +++ b/app/Models/Member.php @@ -9,6 +9,7 @@ class Member extends Authenticatable { use HasFactory; + public $timestamps = false; protected $table = "member"; protected $fillable = ["uuid", "handle", "email", "password", "active", "role", "avatar", "pronoun", "gender"]; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index f639e0e..d345106 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,10 +5,12 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; use App\Repositories\LocationRepository; use App\Repositories\SourceRepository; +use App\Repositories\MemberRepository; use App\Services\UpdateService; use App\Services\MaintenanceService; use App\Models\Location; use App\Models\Source; +use App\Models\Member; class AppServiceProvider extends ServiceProvider { @@ -25,6 +27,10 @@ class AppServiceProvider extends ServiceProvider return new SourceRepository(new Source()); }); + $this->app->bind(MemberRepository::class, function ($app) { + return new MemberRepository(new Member()); + }); + $this->app->bind(UpdateService::class, function ($app) { return new UpdateService( new LocationRepository(new Location()), diff --git a/app/Repositories/MemberRepository.php b/app/Repositories/MemberRepository.php new file mode 100644 index 0000000..ab1456c --- /dev/null +++ b/app/Repositories/MemberRepository.php @@ -0,0 +1,59 @@ +model = $model; + } + + public function get($uuid) + { + return $this->model::where("uuid", $uuid)->first(); + } + + public function edit($request) + { + //get member to edit + $member = $this->get($request->id); + + //save new avi if available + $publicPath = '../public/'; + $refPath = 'assets/images/members/' . $member->uuid; + if ($request->hasfile("fresh_avi")) { + $file = $request->fresh_avi; + if (!is_dir($publicPath . $refPath)) { + mkdir($publicPath . $refPath, 0755, true); + } + $filename = urlencode($file->getClientOriginalName()); + $file->move($publicPath . $refPath, $filename); + $freshAvi = '/' . $refPath . '/' . $filename; + $member->avatar = $freshAvi; + } + //changing password + if (isset($request->fresh_pass) && $request->fresh_pass !== '') { + if ($request->fresh_pass === $request->fresh_pass_confirm) { + $member->password = Hash::make($request->fresh_pass); + } else { + return ['status' => false, 'message' => "Passwords Do Not Match"]; + } + } + + $member->handle = $request->handle; + $member->email = $request->email; + $member->pronoun = $request->pronouns; + + if ($member->save()) { + return ['status' => true, 'message' => "Profile Editited"]; + } else { + return ['status' => false, 'message' => "Profile Not Editited"]; + } + } +} diff --git a/public/assets/css/global/forms.css b/public/assets/css/global/forms.css index 32d16a0..17697ca 100644 --- a/public/assets/css/global/forms.css +++ b/public/assets/css/global/forms.css @@ -36,6 +36,7 @@ input[type="submit"] { border: 0; transition: all 0.3s linear; height: 35px; + margin-top: 15px; } select { diff --git a/public/assets/css/global/frame.css b/public/assets/css/global/frame.css index e2bdef3..eb4e56a 100644 --- a/public/assets/css/global/frame.css +++ b/public/assets/css/global/frame.css @@ -200,7 +200,6 @@ footer { gap: 10px; height: auto; width: auto; - margin: 20px auto; position: relative; } @@ -212,6 +211,15 @@ footer > div:nth-child(2) { text-align: right; } +/* + member stuff + */ + +.your-avatar { + width: 250px; + border-radius: 5px; +} + /* responsive */ diff --git a/public/assets/images/global/default-avi.png b/public/assets/images/global/default-avi.png new file mode 100644 index 0000000..99ee4bb Binary files /dev/null and b/public/assets/images/global/default-avi.png differ diff --git a/resources/views/back/profile.blade.php b/resources/views/back/profile.blade.php index 41fc901..00406b6 100644 --- a/resources/views/back/profile.blade.php +++ b/resources/views/back/profile.blade.php @@ -6,7 +6,8 @@

Edit Profile Deets

- Hi. This is where you change stuff. + @include('forms.profile-edit')
+
@endsection \ No newline at end of file diff --git a/resources/views/forms/profile-edit.blade.php b/resources/views/forms/profile-edit.blade.php new file mode 100644 index 0000000..60ff9c5 --- /dev/null +++ b/resources/views/forms/profile-edit.blade.php @@ -0,0 +1,30 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+

Change Password

+
+ +
+
+ +
+ + +
+ @csrf + + +
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index b4607f5..aaff243 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,6 +5,7 @@ use App\Http\Controllers\FrontIndexController; use App\Http\Controllers\AuthController; use App\Http\Controllers\DenController; use App\Http\Controllers\LocationController; +use App\Http\Controllers\MemberController; use App\Http\Controllers\ExportController; use App\Http\Controllers\AppealController; @@ -49,4 +50,6 @@ Route::group(['prefix' => 'den', 'middleware' => 'member.check'], function () { Route::post("/locations/edit", [LocationController::class, 'editLocation']); Route::get("/admin/update", [LocationController::class, 'updateLocations']); Route::get("/admin/compile", [LocationController::class, 'compileLocations']); + //member actions + Route::post("/profile/edit", [MemberController::class, 'memberEdit']); });