-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
3,843 additions
and
2,051 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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "1.3.4" | ||
".": "1.4.0" | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum Compensation: string | ||
{ | ||
case Paid = 'paid'; | ||
case Volunteer = 'volunteer'; | ||
|
||
public static function labels(): array | ||
{ | ||
return [ | ||
'paid' => __('Paid'), | ||
'volunteer' => __('Volunteer'), | ||
]; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum EngagementSignUpStatus: string | ||
{ | ||
case Open = 'open'; | ||
case Closed = 'closed'; | ||
|
||
public static function labels(): array | ||
{ | ||
return [ | ||
'open' => __('Open'), | ||
'closed' => __('Closed'), | ||
]; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum ProjectInitiator: string | ||
{ | ||
case Organization = 'organization'; | ||
case RegulatedOrganization = 'regulated-organization'; | ||
|
||
public static function labels(): array | ||
{ | ||
return [ | ||
'organization' => __('Community organization'), | ||
'regulated-organization' => __('Regulated organization'), | ||
]; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum SeekingForEngagement: string | ||
{ | ||
case Participants = 'participants'; | ||
case Connectors = 'connectors'; | ||
case Organizations = 'organizations'; | ||
|
||
public static function labels(): array | ||
{ | ||
return [ | ||
'participants' => __('Seeking Individual Consultation Participants'), | ||
'connectors' => __('Seeking Community Connectors'), | ||
'organizations' => __('Seeking Community Organizations to consult with'), | ||
]; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Enums\ProjectInvolvement; | ||
use App\Enums\UserContext; | ||
use App\Models\User; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class UserEngagementsController extends Controller | ||
{ | ||
public function show(): Response|View|RedirectResponse | ||
{ | ||
$user = Auth::user(); | ||
|
||
if ($user->context === UserContext::Organization->value && ! $user->organization) { | ||
return redirect(localized_route('organizations.show-type-selection')); | ||
} | ||
|
||
if ($this->isParticipant($user)) { | ||
$section = ProjectInvolvement::Participating->value; | ||
$activeEngagements = $user->{$user->context}->engagements()->active()->get(); | ||
$completeEngagements = $user->{$user->context}->engagements()->complete()->get(); | ||
} elseif ($this->isConnector($user)) { | ||
$section = ProjectInvolvement::Contracted->value; | ||
$activeEngagements = $user->{$user->context}->connectingEngagements()->active()->get(); | ||
$completeEngagements = $user->{$user->context}->connectingEngagements()->complete()->get(); | ||
} else { | ||
abort(404); | ||
} | ||
|
||
return view('engagements.joined', [ | ||
'section' => $section ?? '', | ||
'showParticipating' => $this->isParticipant($user), | ||
'showConnecting' => $this->isConnector($user), | ||
'activeEngagements' => $activeEngagements ?? [], | ||
'completeEngagements' => $completeEngagements ?? [], | ||
]); | ||
} | ||
|
||
public function showContracted(): Response|View|RedirectResponse | ||
{ | ||
$user = Auth::user(); | ||
|
||
if ($user->context === UserContext::Organization->value && ! $user->organization) { | ||
return redirect(localized_route('organizations.show-type-selection')); | ||
} | ||
|
||
if ($this->isConnector($user)) { | ||
$activeEngagements = $user->{$user->context}->connectingEngagements()->active()->get(); | ||
$completeEngagements = $user->{$user->context}->connectingEngagements()->complete()->get(); | ||
|
||
return view('engagements.joined', [ | ||
'title' => __('Engagements I’ve joined as a Community Connector'), | ||
'section' => 'contracted', | ||
'showParticipating' => $this->isParticipant($user), | ||
'showConnecting' => true, | ||
'activeEngagements' => $activeEngagements, | ||
'completeEngagements' => $completeEngagements, | ||
]); | ||
} | ||
|
||
abort(404); | ||
} | ||
|
||
public function showParticipating(): Response|View|RedirectResponse | ||
{ | ||
$user = Auth::user(); | ||
|
||
if ($user->context === UserContext::Organization->value && ! $user->organization) { | ||
return redirect(localized_route('organizations.show-type-selection')); | ||
} | ||
|
||
if ($this->isParticipant($user)) { | ||
$activeEngagements = $user->{$user->context}->engagements()->active()->get(); | ||
$completeEngagements = $user->{$user->context}->engagements()->complete()->get(); | ||
|
||
return view('engagements.joined', [ | ||
'title' => __('Engagements I’ve joined as a Consultation Participant'), | ||
'section' => 'participating', | ||
'showParticipating' => true, | ||
'showConnecting' => $this->isConnector($user), | ||
'activeEngagements' => $activeEngagements, | ||
'completeEngagements' => $completeEngagements, | ||
]); | ||
} | ||
|
||
abort(404); | ||
} | ||
|
||
public function isParticipant(User $user): bool | ||
{ | ||
$userContext = $user->{$user->context}; | ||
|
||
return $userContext && ($userContext->isParticipant() || $userContext->engagements()->count()); | ||
} | ||
|
||
public function isConnector(User $user): bool | ||
{ | ||
$userContext = $user->{$user->context}; | ||
|
||
return $userContext && ($userContext->isConnector() || $userContext->connectingEngagements()->count()); | ||
} | ||
} |
Oops, something went wrong.