From 0a493b9fff00c4232dbb101cfdad972f03baa41d Mon Sep 17 00:00:00 2001 From: Herpaderp Aldent Date: Wed, 12 Sep 2018 15:56:33 +0200 Subject: [PATCH] Version 1.3.0 (#24) This update is brought to you because and thanks to mmolitor87 & Vojax. Both had very valuable input on how to make SeAT-Groups even better. Thank you for being patient with me, and keep your feedback flowing. * Now respecting all users in a user_group in `isQualified()` method * You are able to setup a whole SeAT Group as manager of another SeAT Group * Refactored edit-view for managed groups * Refactored index-view for managed groups * refactored `isManager()` method * being more strict on membership * Changing Log from STRING to TEXT to accommodate longer messages. * Attempting to modify LogController to resolve an issue with too large DBs * `onFail` now correctly reports to log what went wrong ATTENTION: Managers need now to be extra careful when purging members and make sure they purge all characters from a user_group, whereas before everything was bound to the main_character. If a user lacks of at least 1 character in his user_group which qualifies in respective to your configured affiliation he will get removed from the SeAT group. This means the user will lose every role bound to this SeAT Group and needs to apply/opt-in again. --- CHANGELOG.md | 17 ++++ src/Actions/Managers/AddManagerAction.php | 49 +++++++++++ src/Actions/Managers/RemoveManagerAction.php | 41 ++++++++++ .../Logs/SeatGroupLogsController.php | 2 +- .../Controllers/SeatGroupUserController.php | 46 ++++------- src/Http/Controllers/SeatGroupsController.php | 4 +- .../Validation/Manager/AddManagerRequest.php | 42 ++++++++++ .../Manager/RemoveManagerRequest.php | 42 ++++++++++ src/Http/routes.php | 16 ++-- src/Jobs/GroupSync.php | 17 +++- src/Models/SeatGroup.php | 82 ++++++++++--------- src/config/seatgroups.config.php | 2 +- ...anize_order_of_column_all_corporations.php | 28 +++++++ ..._143438_add_seatgroup_seatgroups_table.php | 34 ++++++++ ...ogs_message_column_from_string_to_text.php | 32 ++++++++ src/lang/en/seat.php | 1 + src/resources/views/edit.blade.php | 59 +------------ src/resources/views/logs/list.blade.php | 3 +- src/resources/views/manager/manager.blade.php | 73 +++++++++++++++++ .../partials/remove-seatgroup.blade.php | 22 +++++ .../partials/remove-usergroup.blade.php | 22 +++++ .../views/partials/auto-group.blade.php | 1 + .../views/partials/join-button.blade.php | 74 ++++++++--------- .../views/partials/managed-group.blade.php | 2 +- 24 files changed, 528 insertions(+), 183 deletions(-) create mode 100644 src/Actions/Managers/AddManagerAction.php create mode 100644 src/Actions/Managers/RemoveManagerAction.php create mode 100644 src/Http/Validation/Manager/AddManagerRequest.php create mode 100644 src/Http/Validation/Manager/RemoveManagerRequest.php create mode 100644 src/database/migrations/2018_09_10_091357_reorganize_order_of_column_all_corporations.php create mode 100644 src/database/migrations/2018_09_10_143438_add_seatgroup_seatgroups_table.php create mode 100644 src/database/migrations/2018_09_12_110559_modify_seatgroup_logs_message_column_from_string_to_text.php create mode 100644 src/resources/views/manager/manager.blade.php create mode 100644 src/resources/views/manager/partials/remove-seatgroup.blade.php create mode 100644 src/resources/views/manager/partials/remove-usergroup.blade.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6008ee3..7f2832f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# Version 1.3.0 +This update is brought to you because and thanks to mmolitor87 & Vojax. Both had very valuable input on how to make SeAT-Groups even better. Thank you for being patient with me, and keep your feedback flowing. + +* Now respecting all users in a user_group in `isQualified()` method +* You are able to setup a whole SeAT Group as manager of another SeAT Group +* Refactored edit-view for managed groups +* Refactored index-view for managed groups +* refactored `isManager()` method +* being more strict on membership +* Changing Log from STRING to TEXT to accommodate longer messages. +* Attempting to modify LogController to resolve an issue with too large DBs +* `onFail` now correctly reports to log what went wrong + +ATTENTION: Managers need now to be extra careful when pruging members and make sure they purge all characters from a user_group, whereas before everything was bound to the main_character. +If a user lacks of at least 1 character in his user_group which qualifies in respective to your configurated affiliation he will get removed from the SeAT group. This means the user will lose every role bound to this SeAT Group and needs to apply/opt-in again. + + # Version 1.2.0 This is a major update to SeAT-Groups as it introduces many asked features and refactoring lots of front end mistakes i made. This is just an initial working release. I will continue to improve SeAT Groups and refactor even classes i have introuced with this release and i see room for improvement. diff --git a/src/Actions/Managers/AddManagerAction.php b/src/Actions/Managers/AddManagerAction.php new file mode 100644 index 0000000..330750f --- /dev/null +++ b/src/Actions/Managers/AddManagerAction.php @@ -0,0 +1,49 @@ +waitlist->map(function($group) { return $group->id; })->toArray())) { + return redirect()->back()->with('warning', 'User must be first member before made manager'); + } + elseif (in_array($group, $seatgroup->member->map(function($group) { return $group->id; })->toArray())) { + $seatgroup->group()->updateExistingPivot($group, [ + 'is_manager' => 1, + ]); + } else { + $seatgroup->group()->attach($group, [ + 'is_manager' => 1, + ]); + } + } + } + + if(isset($data['seatgroups'])){ + + $seatgroup->children()->attach($data['seatgroups']); + + } + + + return redirect()->back()->with('success', 'Updated'); + } + +} \ No newline at end of file diff --git a/src/Actions/Managers/RemoveManagerAction.php b/src/Actions/Managers/RemoveManagerAction.php new file mode 100644 index 0000000..a30ed7c --- /dev/null +++ b/src/Actions/Managers/RemoveManagerAction.php @@ -0,0 +1,41 @@ +group()->updateExistingPivot($group_id, [ + 'is_manager' => 0, + ]); + + } + + if(isset($children_id)){ + + $seatgroup->children()->detach($data['children_id']); + + } + return redirect()->back()->with('success', 'SeAT Group removed'); + + + } + +} \ No newline at end of file diff --git a/src/Http/Controllers/Logs/SeatGroupLogsController.php b/src/Http/Controllers/Logs/SeatGroupLogsController.php index 076ba31..78e71da 100644 --- a/src/Http/Controllers/Logs/SeatGroupLogsController.php +++ b/src/Http/Controllers/Logs/SeatGroupLogsController.php @@ -23,7 +23,7 @@ public function getSeatGroupDeleteButton() public function getSeatGroupLogs() { - $logs = SeatgroupLog::all(); + $logs = SeatgroupLog::query(); return Datatables::of($logs) ->editColumn('created_at', function($row){ diff --git a/src/Http/Controllers/SeatGroupUserController.php b/src/Http/Controllers/SeatGroupUserController.php index ac42631..e15d7bf 100644 --- a/src/Http/Controllers/SeatGroupUserController.php +++ b/src/Http/Controllers/SeatGroupUserController.php @@ -2,6 +2,10 @@ namespace Herpaderpaldent\Seat\SeatGroups\Http\Controllers; +use Herpaderpaldent\Seat\SeatGroups\Actions\Managers\AddManagerAction; +use Herpaderpaldent\Seat\SeatGroups\Actions\Managers\RemoveManagerAction; +use Herpaderpaldent\Seat\SeatGroups\Http\Validation\Manager\AddManagerRequest; +use Herpaderpaldent\Seat\SeatGroups\Http\Validation\Manager\RemoveManagerRequest; use Herpaderpaldent\Seat\SeatGroups\Jobs\GroupSync; use Herpaderpaldent\Seat\SeatGroups\Models\Seatgroup; use Illuminate\Http\Request; @@ -71,53 +75,33 @@ public function removeMember($seat_group_id, $group_id) /** * Display the specified resource. * - * @param int $id + * + * @param \Herpaderpaldent\Seat\SeatGroups\Http\Validation\Manager\RemoveManagerRequest $request + * @param \Herpaderpaldent\Seat\SeatGroups\Actions\Managers\RemoveManagerAction $action + * * @return \Illuminate\Http\Response */ - public function removeManager($seat_group_id, $group_id) + public function removeManager(RemoveManagerRequest $request, RemoveManagerAction $action) { - $seatgroup = Seatgroup::find($seat_group_id); - $seatgroup->group()->updateExistingPivot($group_id, [ - 'is_manager' => 0, - ]); + return $action->execute($request->all()); - return redirect()->back()->with('success', 'Manager removed'); } /** * Show the form for editing the specified resource. * - * @param int $id + * @param \Herpaderpaldent\Seat\SeatGroups\Http\Validation\Manager\AddManagerRequest $request + * @param \Herpaderpaldent\Seat\SeatGroups\Actions\Managers\AddManagerAction $action + * * @return \Illuminate\Http\Response */ - public function addManager(Request $request, $id) + public function addManager(AddManagerRequest $request, AddManagerAction $action) { - // - $seatgroup = Seatgroup::find($id); - - $this->validate(request(),[ - 'groups' => 'required' - ]); + return $action->execute($request->all()); - $groups = $request->get('groups'); - foreach ($groups as $group) { - if (in_array($group, $seatgroup->waitlist->map(function($group) { return $group->id; })->toArray())) { - redirect()->back()->with('warning', 'User must be first member before made manager'); - } - elseif (in_array($group, $seatgroup->member->map(function($group) { return $group->id; })->toArray())) { - $seatgroup->group()->updateExistingPivot($group, [ - 'is_manager' => 1, - ]); - } else { - $seatgroup->group()->attach($group, [ - 'is_manager' => 1, - ]); - } - } - return redirect()->back()->with('success', 'Updated'); } /** diff --git a/src/Http/Controllers/SeatGroupsController.php b/src/Http/Controllers/SeatGroupsController.php index 60facc9..6ffe52f 100644 --- a/src/Http/Controllers/SeatGroupsController.php +++ b/src/Http/Controllers/SeatGroupsController.php @@ -88,7 +88,6 @@ public function show($id) */ public function edit($id, GetCorporationListAction $action) { - // TODO refactor this to $seatgroup->corporation->pluck blabla $all_corporations = $action->execute([ 'seatgroup_id' =>$id, 'origin' => 'SeatGroupsController' @@ -99,9 +98,10 @@ public function edit($id, GetCorporationListAction $action) ]); $roles = Role::all(); $seatgroup = Seatgroup::find($id); + $available_seatgroups = Seatgroup::whereNotIn('id',$seatgroup->children->pluck('id')->push($id)->toArray())->get(); $all_groups = Group::all(); - return view('seatgroups::edit', compact('seatgroup', 'id', 'all_corporations', 'roles', 'corporations', 'all_groups','all_corporations_for_title')); + return view('seatgroups::edit', compact('seatgroup', 'id', 'all_corporations', 'roles', 'corporations', 'all_groups','all_corporations_for_title', 'available_seatgroups')); } /** diff --git a/src/Http/Validation/Manager/AddManagerRequest.php b/src/Http/Validation/Manager/AddManagerRequest.php new file mode 100644 index 0000000..4d1350d --- /dev/null +++ b/src/Http/Validation/Manager/AddManagerRequest.php @@ -0,0 +1,42 @@ +'required', + 'groups' => 'required_if:seatgroups,""', + 'seatgroups' => 'required_if:groups,""', + ]; + } + +} \ No newline at end of file diff --git a/src/Http/Validation/Manager/RemoveManagerRequest.php b/src/Http/Validation/Manager/RemoveManagerRequest.php new file mode 100644 index 0000000..2c8c47d --- /dev/null +++ b/src/Http/Validation/Manager/RemoveManagerRequest.php @@ -0,0 +1,42 @@ +'required', + 'group_id' => 'required_if:children_id,""', + 'children_id' => 'required_if:group_id,""', + ]; + } + +} \ No newline at end of file diff --git a/src/Http/routes.php b/src/Http/routes.php index 6ed394d..89dcc37 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -47,6 +47,14 @@ 'as' => 'seatgroups.create', 'uses' => 'SeatGroupsController@create', ]); + Route::post('/manager/add', [ + 'as' => 'seatgroupuser.addmanager', + 'uses' => 'SeatGroupUserController@addManager', + ]); + Route::post('/manager/remove', [ + 'as' => 'seatgroupuser.remove.manager', + 'uses' => 'SeatGroupUserController@removeManager', + ]); }); @@ -150,14 +158,6 @@ 'middleware' => 'bouncer:seatgroups.create', 'uses' => 'SeatGroupUserController@removeGroupFromSeatGroup', ]); - Route::post('/{group_id}/manager', [ - 'as' => 'seatgroupuser.addmanager', - 'uses' => 'SeatGroupUserController@addManager', - ]); - Route::delete('/{seat_group_id}/manager/{group_id}', [ - 'as' => 'seatgroupuser.removemanager', - 'uses' => 'SeatGroupUserController@removeManager', - ]); Route::delete('/{seat_group_id}/member/{group_id}', [ 'as' => 'seatgroupuser.removemember', 'uses' => 'SeatGroupUserController@removeMember', diff --git a/src/Jobs/GroupSync.php b/src/Jobs/GroupSync.php index 0eed507..fa4c997 100644 --- a/src/Jobs/GroupSync.php +++ b/src/Jobs/GroupSync.php @@ -70,6 +70,10 @@ public function handle() foreach ($seat_group->role as $role) { $roles->push($role->id); } + if(!in_array($group->id,$seat_group->member->pluck('id')->toArray())){ + // add user_group to seat_group as member if no member yet. + $seat_group->member()->attach($group->id); + } break; case 'open': case 'managed': @@ -82,8 +86,9 @@ public function handle() } break; } + } else if(in_array($group->id,$seat_group->member->pluck('id')->toArray())) { + $seat_group->member()->detach($group->id); } - }); $group->roles()->sync($roles->unique()); @@ -117,6 +122,9 @@ public function beforeStart() if (is_null($user->refresh_token)) { // take away all roles $this->group->roles()->sync([]); + Seatgroup::all()->each(function ($seatgroup) { + $seatgroup->member->detach($this->group->id); + }); SeatgroupLog::create([ 'event' => 'warning', @@ -134,19 +142,22 @@ public function beforeStart() public function onFail($exception) { + report($exception); + SeatgroupLog::create([ 'event' => 'error', - 'message' => sprintf('An error occurred while syncing user group of %s (%s)', + 'message' => sprintf('An error occurred while syncing user group of %s (%s). Please check the logs.', $this->group->main_character->name, $this->group->users->map(function($user) { return $user->name; })->implode(', ')) ]); + } public function onFinish() { SeatgroupLog::create([ 'event' => 'success', - 'message' => sprintf('The user group of %s (%s) has successfully been synced', + 'message' => sprintf('The user group of %s (%s) has successfully been synced.', $this->group->main_character->name, $this->group->users->map(function($user) { return $user->name; })->implode(', ')) ]); diff --git a/src/Models/SeatGroup.php b/src/Models/SeatGroup.php index 32fa701..8444bcb 100644 --- a/src/Models/SeatGroup.php +++ b/src/Models/SeatGroup.php @@ -66,12 +66,24 @@ public function waitlist() ->wherePivot('on_waitlist', 1); } + /** + * @param \Seat\Web\Models\Group $group + * + * @return bool + */ public function isManager(Group $group) { if (in_array($group->id, $this->manager->pluck('id')->toArray())) return true; + if($this->children){ + foreach ($this->children as $child) { + if(in_array($group->id, $child->member->pluck('id')->toArray())) + return true; + } + } + return false; } @@ -84,7 +96,7 @@ public function isManager(Group $group) public function isAllowedToSeeSeatGroup() { - if (auth()->user()->hasSuperUser() || auth()->user()->hasRole('seatgroups.edit')) + if (auth()->user()->hasSuperUser() || auth()->user()->hasRole('seatgroups.edit') || $this->isManager(auth()->user()->group)) return true; return $this->isQualified(auth()->user()->group); @@ -100,29 +112,18 @@ public function onWaitlist() })->toArray()); } + /** + * @param \Seat\Web\Models\Group $group + * + * @return bool + */ public function isMember(Group $group) { - try { - - switch ($this->type) { - - case 'auto': - if ($this->isQualified($group)) - return true; - break; - case 'open': - case 'managed': - case 'hidden': - if (in_array($group->id, $this->member->pluck('id')->toArray())) - return true; - break; - } + if (in_array($group->id, $this->member->pluck('id')->toArray())) + return true; - return false; - } catch (\Exception $e) { - return $e; - } + return false; } public function isQualified(Group $group) @@ -133,35 +134,38 @@ public function isQualified(Group $group) return true; $affiliations = collect($action->execute(['seatgroup_id' => $this->id])); - $main_character = $group->main_character; - $affiliations = $affiliations->filter(function ($affiliation) use ($main_character) { + foreach ($group->users as $user){ - if (isset($affiliation['corporation_title'])) { - //Handle Corp_title - // First check if corporation is equal to main_character corporation. - if ($affiliation['corporation_id'] === $main_character->corporation_id) { - //Then check if tite_id is within main_characters titles - if (in_array($affiliation['corporation_title']['title_id'], $main_character->titles->pluck('title_id')->toArray())) { + foreach($affiliations as $affiliation){ - return true; + if (isset($affiliation['corporation_title'])) { + // Handle Corp_title + // First check if corporation is equal to character corporation. + if ($affiliation['corporation_id'] === $user->character->corporation_id) { + //Then check if tite_id is within main_characters titles + if (in_array($affiliation['corporation_title']['title_id'], $user->character->titles->pluck('title_id')->toArray())) { + + return true; + } } } - } - - //Check if main_character is an affiliated corporation - if ($affiliation['corporation_id'] === $main_character->corporation_id && ! isset($affiliation['corporation_title'])) { - - return true; - } - }); + //Check if main_character is an affiliated corporation + if (isset($affiliation['corporation_id']) && $affiliation['corporation_id'] === $user->character->corporation_id && ! isset($affiliation['corporation_title'])) { + return true; + } - if ($affiliations->isNotEmpty()) - return true; + } + } return false; } + + public function children() + { + return $this->belongsToMany(Seatgroup::class, 'seatgroup_seatgroups','parent_id','child_id'); + } } diff --git a/src/config/seatgroups.config.php b/src/config/seatgroups.config.php index 0fecef4..be6f840 100644 --- a/src/config/seatgroups.config.php +++ b/src/config/seatgroups.config.php @@ -6,7 +6,7 @@ * Time: 10:24 */ return [ - 'version' => '1.2.0' + 'version' => '1.3.0' ]; //TODO: Update Version \ No newline at end of file diff --git a/src/database/migrations/2018_09_10_091357_reorganize_order_of_column_all_corporations.php b/src/database/migrations/2018_09_10_091357_reorganize_order_of_column_all_corporations.php new file mode 100644 index 0000000..86b84ce --- /dev/null +++ b/src/database/migrations/2018_09_10_091357_reorganize_order_of_column_all_corporations.php @@ -0,0 +1,28 @@ +increments('id'); + $table->integer('child_id')->unsigned()->index(); + $table->integer('parent_id')->unsigned()->index(); + $table->foreign('child_id')->references('id')->on('seatgroups')->onDelete('cascade'); + $table->foreign('parent_id')->references('id')->on('seatgroups')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('seatgroup_seatgroups'); + } +} diff --git a/src/database/migrations/2018_09_12_110559_modify_seatgroup_logs_message_column_from_string_to_text.php b/src/database/migrations/2018_09_12_110559_modify_seatgroup_logs_message_column_from_string_to_text.php new file mode 100644 index 0000000..8592b6a --- /dev/null +++ b/src/database/migrations/2018_09_12_110559_modify_seatgroup_logs_message_column_from_string_to_text.php @@ -0,0 +1,32 @@ +text('message')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('seatgroup_logs', function (Blueprint $table) { + $table->string('message')->change(); + }); + } +} diff --git a/src/lang/en/seat.php b/src/lang/en/seat.php index 119e2d9..b79d773 100644 --- a/src/lang/en/seat.php +++ b/src/lang/en/seat.php @@ -30,6 +30,7 @@ 'seat_deny_managedgroup' => 'Reject', 'seat_accept_managedgroup' => 'Accept', 'seat_removefrom_managedgroup' => 'Remove', + 'available_seatgroups' => 'Available SeAT Groups as Manager', 'seat_groups_hiddengroup' => 'Hidden SeAT Group', 'seat_groups_user' => 'User', diff --git a/src/resources/views/edit.blade.php b/src/resources/views/edit.blade.php index 321d4e6..ba34b1e 100644 --- a/src/resources/views/edit.blade.php +++ b/src/resources/views/edit.blade.php @@ -120,66 +120,9 @@
@if($seatgroup->type == 'managed') -

{{trans('seatgroups::seat.seat_groups_managedgroup')}}

-
-
-

{{trans('seatgroups::seat.seat_groups_manager')}}

-
-
-
- {{csrf_field()}} - -
- - -
-
-
-
- -
-
-
-
- - - - - - - @foreach($seatgroup->manager as $group) - - - - - - @endforeach - - -
Current Manager
- {{ $group->users->map(function($user) { return $user->name; })->implode(', ') }} - - {!! Form::open(['method' => 'DELETE', - 'route' => ['seatgroupuser.removemanager',$seatgroup->id,$group->id], - 'style'=>'display:inline' - ]) !!} - {!! Form::submit(trans('web::seat.remove'), ['class' => 'btn btn-danger btn-xs pull-right']) !!} - {!! Form::close() !!} -
-
-
+ @include('seatgroups::manager.manager') @endif @if($seatgroup->type == 'hidden') diff --git a/src/resources/views/logs/list.blade.php b/src/resources/views/logs/list.blade.php index a9cab70..90083ac 100644 --- a/src/resources/views/logs/list.blade.php +++ b/src/resources/views/logs/list.blade.php @@ -20,8 +20,7 @@ {data: 'created_at'}, {data: 'event', name: 'event'}, {data: 'message'} - ], - order: [[0,'desc']] + ] }); }); diff --git a/src/resources/views/manager/manager.blade.php b/src/resources/views/manager/manager.blade.php new file mode 100644 index 0000000..16f418c --- /dev/null +++ b/src/resources/views/manager/manager.blade.php @@ -0,0 +1,73 @@ +

{{trans('seatgroups::seat.seat_groups_managedgroup')}}

+
+
+

{{trans('seatgroups::seat.seat_groups_manager')}}

+
+ +
+
+ {{csrf_field()}} + + +
+ + +
+
+ + +
+ +
+
+
+ +
+
+
+ + + + + + + + + @include('seatgroups::manager.partials.remove-usergroup') + @include('seatgroups::manager.partials.remove-seatgroup') + + +
Current Manager
+ +
+ +
+ +@push('javascript') + + @include('web::includes.javascript.id-to-name') + + + +@endpush \ No newline at end of file diff --git a/src/resources/views/manager/partials/remove-seatgroup.blade.php b/src/resources/views/manager/partials/remove-seatgroup.blade.php new file mode 100644 index 0000000..e8a2e54 --- /dev/null +++ b/src/resources/views/manager/partials/remove-seatgroup.blade.php @@ -0,0 +1,22 @@ +@foreach($seatgroup->children as $row) + + + {{$row->name}} SeAT Group + {{--{{ $row->children->map(function($user) { return $user->name; })->implode(', ') }}--}} + + + +
+ {{ csrf_field() }} + + + + +
+ + + + +@endforeach diff --git a/src/resources/views/manager/partials/remove-usergroup.blade.php b/src/resources/views/manager/partials/remove-usergroup.blade.php new file mode 100644 index 0000000..7f3476a --- /dev/null +++ b/src/resources/views/manager/partials/remove-usergroup.blade.php @@ -0,0 +1,22 @@ +@foreach($seatgroup->manager as $row) + + + {{ $row->users->map(function($user) { return $user->name; })->implode(', ') }} + + + +
+ {{ csrf_field() }} + + + + + +
+ + + + +@endforeach diff --git a/src/resources/views/partials/auto-group.blade.php b/src/resources/views/partials/auto-group.blade.php index d156bd0..667172f 100644 --- a/src/resources/views/partials/auto-group.blade.php +++ b/src/resources/views/partials/auto-group.blade.php @@ -12,6 +12,7 @@ @foreach($seatgroups->where('type', 'auto') as $seatgroup) + @if(!$seatgroup->isAllowedToSeeSeatGroup()) @continue @endif diff --git a/src/resources/views/partials/join-button.blade.php b/src/resources/views/partials/join-button.blade.php index 3b1f7f9..4bdfa94 100644 --- a/src/resources/views/partials/join-button.blade.php +++ b/src/resources/views/partials/join-button.blade.php @@ -1,43 +1,43 @@ @switch($seatgroup->type) @case('open') - @switch($seatgroup->isMember(auth()->user()->group)) - @case(false) -
- {{csrf_field()}} - - -
- @break - @case(true) -
- {{csrf_field()}} - -
- @break - @endswitch + @switch($seatgroup->isMember(auth()->user()->group)) + @case(false) +
+ {{csrf_field()}} + + +
+ @break + @case(true) +
+ {{csrf_field()}} + +
+ @break + @endswitch @case('managed') - @if($seatgroup->onWaitlist()) -
- {{csrf_field()}} - -
- @break - @endif - @switch($seatgroup->isMember(auth()->user()->group)) - @case(false) -
- {{csrf_field()}} - - -
- @break - @case(true) -
- {{csrf_field()}} - -
- @break - @endswitch + @if($seatgroup->onWaitlist()) +
+ {{csrf_field()}} + +
+ @break + @endif + @switch($seatgroup->isMember(auth()->user()->group)) + @case(false) +
+ {{csrf_field()}} + + +
+ @break + @case(true) +
+ {{csrf_field()}} + +
+ @break + @endswitch @endswitch diff --git a/src/resources/views/partials/managed-group.blade.php b/src/resources/views/partials/managed-group.blade.php index 2acb98c..d24931e 100644 --- a/src/resources/views/partials/managed-group.blade.php +++ b/src/resources/views/partials/managed-group.blade.php @@ -11,7 +11,7 @@

{{$seatgroup->name}}

- @include('seatgroups::partials.join-button') + @includeWhen($seatgroup->isQualified(auth()->user()->group),'seatgroups::partials.join-button') {{$seatgroup->description}}
@if($seatgroup->isMember(auth()->user()->group)) Members: {{$seatgroup->member->map(function($group) { return $group->main_character->name;})->implode(', ')}}