-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from RiwRiwara/AdminSystem
Admin system
- Loading branch information
Showing
15 changed files
with
673 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/Http/Controllers/Admin/Event/EventDetailController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\Event; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use App\Models\Event; | ||
|
||
class EventDetailController extends Controller | ||
{ | ||
const TEMPLATE_PAGE = 'admin.event-detail'; | ||
|
||
public function __invoke(Request $request, $event_id) | ||
{ | ||
$event = Event::where('event_id', $event_id)->firstOrFail(); | ||
$this->authorize('view', $event); | ||
|
||
$event_types = $this->prepate_type_data($event); | ||
$event->event_types = $event_types; | ||
|
||
$Summary = $event->getSummary(); | ||
|
||
$page_data = [ | ||
'breadcrumbItems' => [ | ||
['label' => 'Events Dashboard', 'url' => route('events-dashboard')], | ||
['label' => $event->event_name], | ||
], | ||
'event_types' => \App\Models\EventType::all(), | ||
'badge_types' => \App\Models\Badge::all(), | ||
'default_event_img' => config('azure.default_img.event_banner'), | ||
]; | ||
|
||
return view(EventDetailController::TEMPLATE_PAGE, compact('page_data', 'event')); | ||
} | ||
|
||
|
||
private function prepate_type_data($event) | ||
{ | ||
$event_types = $event->categories; | ||
$event_types = explode(',', $event_types); | ||
|
||
$event_types = collect($event_types)->map(function ($event_type) { | ||
return 'type_' . $event_type; | ||
}); | ||
|
||
return $event_types; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\Users; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\ProfileUpdateRequest; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Redirect; | ||
use Illuminate\Http\Request; | ||
use App\Constants\Cities; | ||
use App\Constants\Districts; | ||
use App\Constants\Provinces; | ||
use App\Constants\Gender; | ||
use App\Constants\Time; | ||
use App\Models\User; | ||
|
||
class UserDetailController extends Controller | ||
{ | ||
public function __invoke(Request $request, $user_id) | ||
{ | ||
|
||
$user = User::where('user_id', $user_id)->first(); | ||
if (!$user) { | ||
toastr()->addError('User not found'); | ||
return redirect()->back(); | ||
} | ||
$isThai = app()->getLocale() === 'th'; | ||
|
||
$user->gender = Gender::getGenderById($user->gender); | ||
$user->date_of_birth = (new Time($user->date_of_birth, $isThai))->getDateBirthObject(); | ||
|
||
$page_data = [ | ||
'isThai' => $isThai, | ||
'provinces' => Provinces::provinces(), | ||
'districts' => Cities::cities(), | ||
'cities' => Districts::districts(), | ||
'gender' => Gender::gender(), | ||
'breadcrumbItems' => [ | ||
['label' => 'User Dashboard', 'url' => route('users-dashboard')], | ||
['label' => $user->first_name . ' ' . $user->last_name], | ||
] | ||
|
||
]; | ||
|
||
return view('admin.profileDetail', compact('user', 'page_data')); | ||
} | ||
/** | ||
* Update the user's profile information. | ||
*/ | ||
public function update(ProfileUpdateRequest $request): RedirectResponse | ||
{ | ||
$request->user()->fill($request->validated()); | ||
|
||
if ($request->user()->isDirty('email')) { | ||
$request->user()->email_verified_at = null; | ||
} | ||
|
||
$request->user()->save(); | ||
|
||
toastr()->addSuccess(__('success.profile_update')); | ||
|
||
return Redirect::route('profile.edit')->with('status', 'profile-updated'); | ||
} | ||
|
||
/** | ||
* Delete the user's account. | ||
*/ | ||
public function destroy(Request $request): RedirectResponse | ||
{ | ||
$request->validateWithBag('userDeletion', [ | ||
'password' => ['required', 'current_password'], | ||
]); | ||
|
||
$user = $request->user(); | ||
|
||
Auth::logout(); | ||
|
||
$user->delete(); | ||
|
||
$request->session()->invalidate(); | ||
$request->session()->regenerateToken(); | ||
|
||
return Redirect::to('/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.