New Member Info
+ @include('forms.member-edit') +@break @default @@ -21,6 +31,8 @@ @foreach($members as $member) {{$member->handle}}
@endforeach +
Add Member
+ Make a new friend@endswitch
diff --git a/app/Http/Controllers/MemberController.php b/app/Http/Controllers/MemberController.php
index 741a644..50db498 100644
--- a/app/Http/Controllers/MemberController.php
+++ b/app/Http/Controllers/MemberController.php
@@ -62,6 +62,13 @@ class MemberController extends Controller
'title' => "Edit Member Info"]);
}
+ public function createMember(Request $Request)
+ {
+ return view('back.member', [
+ 'mode' => 'member-create',
+ 'title' => "Make a new friend"]);
+ }
+
//actions
public function profileEdit(Request $request)
{
@@ -84,4 +91,15 @@ class MemberController extends Controller
return back()->withErrors([$response['message']]);
}
}
+
+ public function memberCreate(Request $request)
+ {
+ $token = csrf_token();
+ $response = $this->member->add($request);
+ if ($response['status'] == true) {
+ return redirect('/den/member')->with('message', $response['message']);
+ } else {
+ return back()->withErrors([$response['message']]);
+ }
+ }
}
diff --git a/app/Models/Member.php b/app/Models/Member.php
index f4397d6..9ebe01d 100644
--- a/app/Models/Member.php
+++ b/app/Models/Member.php
@@ -9,7 +9,20 @@ class Member extends Authenticatable
{
use HasFactory;
- public $timestamps = false;
- protected $table = "member";
- protected $fillable = ["uuid", "handle", "email", "password", "active", "role", "avatar", "pronoun", "gender"];
+ public $timestamps = false;
+ protected $table = "member";
+ protected $primaryKey = 'id';
+ public $incrementing = true;
+ protected $fillable = [
+ "uuid",
+ "handle",
+ "email",
+ "password",
+ "active",
+ "role",
+ "avatar",
+ "pronoun",
+ "created_at",
+ "last_login"
+ ];
}
diff --git a/app/Repositories/MemberRepository.php b/app/Repositories/MemberRepository.php
index 8ff8006..bbb7305 100644
--- a/app/Repositories/MemberRepository.php
+++ b/app/Repositories/MemberRepository.php
@@ -4,6 +4,8 @@ namespace App\Repositories;
use App\Models\Member;
use Illuminate\Support\Facades\Hash;
+use Ramsey\Uuid\Uuid;
+use Carbon\Carbon;
class MemberRepository
{
@@ -56,6 +58,35 @@ class MemberRepository
}
}
+ public function add($request)
+ {
+ $password = [];
+ if ($request->fresh_pass === $request->fresh_pass_confirm) {
+ $password = Hash::make($request->fresh_pass);
+ } else {
+ return ['status' => false, 'message' => "Passwords Do Not Match"];
+ }
+
+ $newFriend = $this->model::create([
+ 'uuid' => Uuid::uuid4(),
+ 'avatar' => 'default-member-avatar',
+ 'handle' => $request->handle,
+ 'email' => $request->email,
+ 'pronoun' => $request->pronouns,
+ 'role' => $request->role,
+ 'active' => $request->status,
+ 'password' => $password,
+ 'created_at' => Carbon::now(),
+ 'last_login' => Carbon::now(),
+ ]);
+
+ if ($newFriend) {
+ return ['status' => true, 'message' => "New Friend Made!"];
+ } else {
+ return ['status' => false, 'message' => "Uh oh, New Friend Delay!"];
+ }
+ }
+
public function editProfile($request)
{
//get member to edit
diff --git a/resources/views/back/listings.php b/resources/views/back/listings.blade.php
similarity index 100%
rename from resources/views/back/listings.php
rename to resources/views/back/listings.blade.php
diff --git a/resources/views/back/member.blade.php b/resources/views/back/member.blade.php
index e2af712..1f3b1de 100644
--- a/resources/views/back/member.blade.php
+++ b/resources/views/back/member.blade.php
@@ -2,6 +2,14 @@
@section('title', 'Den | Member Admin')
+ @php
+ if($mode == 'member-create')
+ {
+ $action_url = '/den/member/create';
+ }else{
+ $action_url = '/den/member/edit';
+ }
+ @endphp
@section('main-content')
New Member Info
+ @include('forms.member-edit')
+
@break
@default
@@ -21,6 +31,8 @@
@foreach($members as $member)
{{$member->handle}}
@endforeach
+ Add Member
+ Make a new friend
@endswitch