2024-09-20 23:09:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2024-09-25 00:21:59 +02:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2024-09-20 23:09:45 +02:00
|
|
|
use App\Repositories\MemberRepository;
|
|
|
|
|
|
|
|
class MemberController extends Controller
|
|
|
|
{
|
2024-09-25 00:21:59 +02:00
|
|
|
protected $member;
|
2024-09-20 23:09:45 +02:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
MemberRepository $memberRepo
|
|
|
|
) {
|
2024-09-25 00:21:59 +02:00
|
|
|
$this->member = $memberRepo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
|
|
|
$member = Auth::user();
|
|
|
|
return view('back.member', [
|
|
|
|
'handle' => $member->handle,
|
|
|
|
'members' => $this->member->getAll(),
|
|
|
|
'mode' => 'index',
|
|
|
|
'title' => "Manage Members"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
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', [
|
|
|
|
'title' => "Hey, it's you!",
|
|
|
|
'handle' => $member->handle,
|
|
|
|
'email' => $member->email,
|
|
|
|
'avatar' => $avi,
|
|
|
|
'pronouns' => $member->pronoun,
|
|
|
|
'uuid' => $member->uuid,
|
|
|
|
'role' => $member->role
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editMember(Request $request, $uuid = 0)
|
|
|
|
{
|
|
|
|
$member = $this->member->get($uuid);
|
|
|
|
$avi = '';
|
|
|
|
if ($member->avatar == 'default-member-avatar') {
|
|
|
|
$avi = '/assets/images/global/default-avi.png';
|
|
|
|
} else {
|
|
|
|
$avi = $member->avatar;
|
|
|
|
}
|
|
|
|
return view('back.member', [
|
|
|
|
'member' => $member,
|
|
|
|
'avatar' => $avi,
|
|
|
|
'mode' => 'member-edit',
|
|
|
|
'title' => "Edit Member Info"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//actions
|
|
|
|
public function profileEdit(Request $request)
|
|
|
|
{
|
|
|
|
$token = csrf_token();
|
|
|
|
$response = $this->member->editProfile($request);
|
|
|
|
if ($response['status'] == true) {
|
|
|
|
return back()->with('message', $response['message']);
|
|
|
|
} else {
|
|
|
|
return back()->withErrors([$response['message']]);
|
|
|
|
}
|
2024-09-20 23:09:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function memberEdit(Request $request)
|
|
|
|
{
|
|
|
|
$token = csrf_token();
|
2024-09-25 00:21:59 +02:00
|
|
|
$response = $this->member->edit($request);
|
2024-09-20 23:09:45 +02:00
|
|
|
if ($response['status'] == true) {
|
|
|
|
return back()->with('message', $response['message']);
|
|
|
|
} else {
|
|
|
|
return back()->withErrors([$response['message']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|