Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch to Hearth Components, remove Hearth, upgrade to Laravel 11 #2375

Merged
merged 12 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function update($user, array $input)
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add(
'current_password',
__('hearth::auth.wrong_password')
__('auth.wrong_password')
);
}
})->validateWithBag('updatePassword');
Expand Down
2 changes: 0 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,5 @@ protected function schedule(Schedule $schedule)
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/ContractorInvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function accept(Request $request, Invitation $invitation): RedirectRespon
}

flash(
__('You have joined :invitationable as a :role', ['invitationable' => $invitation->invitationable->name, 'role' => $invitation->role]),
__('You have joined :invitationable as a :role', ['invitationable' => $invitation->invitationable->getTranslation('name', locale()), 'role' => $invitation->role]),
'success|'.__('You have joined as a :role', ['role' => $invitation->role], 'en')
);

Expand Down Expand Up @@ -74,12 +74,12 @@ public function decline(Request $request, Invitation $invitation): RedirectRespo
$invitation->type === 'individual'
? __('You have declined your invitation to work as a :role on :invitationable.', [
'role' => $invitation->role,
'invitationable' => $invitation->invitationable->name,
'invitationable' => $invitation->invitationable->getTranslation('name', locale()),
])
: __('You have declined an invitation on behalf of your organization, :organization, to work as a :role on :invitationable.', [
'organization' => $request->user()->organization->name,
'role' => $invitation->role,
'invitationable' => $invitation->invitationable->name,
'invitationable' => $invitation->invitationable->getTranslation('name', locale()),
]),
$invitation->type === 'individual'
? 'success|'.__('You have declined your invitation to work.', [], 'en')
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/EngagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use App\Models\AccessSupport;
use App\Models\Engagement;
use App\Models\Identity;
use App\Models\Invitation;
use App\Models\Language;
use App\Models\MatchingStrategy;
use App\Models\Organization;
Expand Down Expand Up @@ -177,6 +178,7 @@ public function criteriaSelection(Engagement $engagement): View

public function updateCriteria(UpdateEngagementSelectionCriteriaRequest $request, Engagement $engagement): RedirectResponse
{
/** @var MatchingStrategy */
$matchingStrategy = $engagement->matchingStrategy;

$engagementData = $request->safe()->only(['ideal_participants', 'minimum_participants']);
Expand All @@ -202,10 +204,10 @@ public function updateCriteria(UpdateEngagementSelectionCriteriaRequest $request

$matchingStrategy->fill($matchingStrategyData);

$matchingStrategy->extra_attributes->intersectional = $matchingStrategyData['intersectional'];
$matchingStrategy->extra_attributes['intersectional'] = $matchingStrategyData['intersectional'];

if ($matchingStrategyData['intersectional'] == 0) {
$matchingStrategy->extra_attributes->other_identity_type = $matchingStrategyData['other_identity_type'];
$matchingStrategy->extra_attributes['other_identity_type'] = $matchingStrategyData['other_identity_type'];
if ($matchingStrategyData['other_identity_type'] === IdentityType::AgeBracket->value) {
$matchingStrategy->languages()->detach();
$matchingStrategy->syncMutuallyExclusiveIdentities(
Expand Down Expand Up @@ -438,9 +440,10 @@ public function manage(Engagement $engagement)
}
}

/** @var ?Invitation */
$connectorInvitation = $engagement->invitations->where('role', 'connector')->first() ?? null;
$connectorInvitee = null;
if ($connectorInvitation) {
if (! is_null($connectorInvitation)) {
if ($connectorInvitation->type === 'individual') {
$individual = $this->retrieveUserByEmail($connectorInvitation->email)?->individual;
$connectorInvitee = $individual && $individual->checkStatus('published') ? $individual : null;
Expand Down Expand Up @@ -509,6 +512,7 @@ public function addOrganization(Request $request, Engagement $engagement): Redir

public function removeOrganization(Request $request, Engagement $engagement): RedirectResponse
{
/** @var Organization */
$organization = $engagement->organization;

$engagement->organization()->dissociate();
Expand Down Expand Up @@ -593,6 +597,7 @@ public function inviteParticipant(Request $request, Engagement $engagement): Red
$validated['type'] = 'individual';
$validated['role'] = 'participant';

/** @var Invitation */
$invitation = $engagement->invitations()->create($validated);

if ($user) {
Expand Down
24 changes: 24 additions & 0 deletions app/Http/Controllers/HealthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Events\DiagnosingHealth;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Event;

class HealthController extends Controller
{
public function show(Request $request): JsonResponse
{
$status = [];

Event::dispatch(new DiagnosingHealth);

if (defined('LARAVEL_START')) {
$status['duration'] = round((microtime(true) - LARAVEL_START) * 1000).'ms';
}

return response()->json($status);
}
}
4 changes: 1 addition & 3 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ public function update(UpdateProjectRequest $request, Project $project): Redirec
$project->fill($data);
$project->save();

if (isset($data['impacts'])) {
$project->impacts()->sync($data['impacts'] ?? []);
}
$project->impacts()->sync(isset($data['impacts']) ? $data['impacts'] : []);

return $project->handleUpdateRequest($request, 1);
}
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,23 @@ public function updateAccessNeeds(UpdateAccessNeedsRequest $request): RedirectRe
$data['other_access_need'] = null;
}

if (! isset($data['meeting_access_needs']) || (isset($data['meeting_access_needs']) && ! in_array($signLanguageInterpretation, $data['meeting_access_needs']))) {
if (! isset($data['meeting_access_needs']) || ! in_array($signLanguageInterpretation, $data['meeting_access_needs'])) {
$data['signed_language_for_interpretation'] = null;
}

if (! isset($data['meeting_access_needs']) || (isset($data['meeting_access_needs']) && ! in_array($spokenLanguageInterpretation, $data['meeting_access_needs']))) {
if (! isset($data['meeting_access_needs']) || ! in_array($spokenLanguageInterpretation, $data['meeting_access_needs'])) {
$data['spoken_language_for_interpretation'] = null;
}

if (! isset($data['document_access_needs']) || (isset($data['document_access_needs']) && ! in_array($signLanguageTranslation, $data['document_access_needs']))) {
if (! isset($data['document_access_needs']) || ! in_array($signLanguageTranslation, $data['document_access_needs'])) {
$data['signed_language_for_translation'] = null;
}

if (! isset($data['document_access_needs']) || (isset($data['document_access_needs']) && ! in_array($writtenLanguageTranslation, $data['document_access_needs']))) {
if (! isset($data['document_access_needs']) || ! in_array($writtenLanguageTranslation, $data['document_access_needs'])) {
$data['written_language_for_translation'] = null;
}

if (! isset($data['document_access_needs']) || (isset($data['document_access_needs']) && ! in_array($printedVersion, $data['document_access_needs']))) {
if (! isset($data['document_access_needs']) || ! in_array($printedVersion, $data['document_access_needs'])) {
$data['street_address'] = null;
$data['unit_apartment_suite'] = null;
$data['postal_code'] = null;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function add(AddTranslationRequest $request)

$languages = $model->languages;
$languages[] = $data['new_language'];
$model->update(['languages' => array_values($languages)]);
$model->update(['languages' => $languages]);

flash(__('Language :language added.', ['language' => get_language_exonym($data['new_language'])]), 'success|'.__('Language added.', [], 'en'));

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function destroy(DestroyUserRequest $request)

$user->delete();

flash(__('hearth::user.destroy_succeeded'), 'success|'.__('hearth::user.destroy_succeeded', [], 'en'));
flash(__('user.destroy_succeeded'), 'success|'.__('user.destroy_succeeded', [], 'en'));

return redirect(localized_route('welcome'));
}
Expand Down
14 changes: 7 additions & 7 deletions app/Http/Controllers/UserEngagementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ public function show(): Response|View|RedirectResponse

if ($this->isParticipant($user)) {
$section = ProjectInvolvement::Participating->value;
$activeEngagements = $user->{$user->context}->engagements()->active()->get();
$completeEngagements = $user->{$user->context}->engagements()->complete()->get();
$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();
$activeEngagements = $user->{$user->context}->connectingEngagements()->active()->get() ?? [];
$completeEngagements = $user->{$user->context}->connectingEngagements()->complete()->get() ?? [];
} else {
abort(404);
}

return view('engagements.joined', [
'section' => $section ?? '',
'section' => $section,
'showParticipating' => $this->isParticipant($user),
'showConnecting' => $this->isConnector($user),
'activeEngagements' => $activeEngagements ?? [],
'completeEngagements' => $completeEngagements ?? [],
'activeEngagements' => $activeEngagements,
'completeEngagements' => $completeEngagements,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/VerifyEmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __invoke(VerifyEmailRequest $request): RedirectResponse
event(new Verified($request->user()));
}

flash(__('hearth::auth.verification_succeeded', [], $request->user()->locale), 'success|'.__('hearth::auth.verification_succeeded', [], 'en'));
flash(__('auth.verification_succeeded', [], $request->user()->locale), 'success|'.__('auth.verification_succeeded', [], 'en'));

return redirect()->intended($dashboard);
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Middleware/EnsureEmailIsVerified.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
Expand All @@ -17,8 +16,7 @@ class EnsureEmailIsVerified
public function handle(Request $request, Closure $next, ?string $redirectToRoute = null): Response|RedirectResponse|null
{
if (! $request->user() ||
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
! $request->user()->hasVerifiedEmail()) {
return Redirect::guest(localized_route($redirectToRoute ?: 'verification.notice'));
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/DestroyUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function withValidator(Validator $validator)
if (! Hash::check($this->current_password, $this->user()->password)) {
$validator->errors()->add(
'current_password',
__('hearth::auth.wrong_password')
__('auth.wrong_password')
);
}
if ($this->user()->isOnlyAdministratorOfOrganization()) {
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/MeetingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
use Worksome\RequestFactories\Concerns\HasFactory;

class MeetingRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return true;
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/StoreEngagementRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Worksome\RequestFactories\Concerns\HasFactory;

class StoreEngagementRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return $this->user()->can('update', $this->project);
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/StoreOrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use App\Enums\OrganizationType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
use Worksome\RequestFactories\Concerns\HasFactory;

class StoreOrganizationRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return true;
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/StoreProjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Worksome\RequestFactories\Concerns\HasFactory;

class StoreProjectRequest extends FormRequest
{
use HasFactory;

/**
* Determine if the user is authorized to make this request.
*
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/StoreRegulatedOrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Worksome\RequestFactories\Concerns\HasFactory;

class StoreRegulatedOrganizationRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return true;
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/UpdateEngagementRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
use Worksome\RequestFactories\Concerns\HasFactory;

class UpdateEngagementRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return $this->user()->can('update', $this->engagement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
use Worksome\RequestFactories\Concerns\HasFactory;

class UpdateEngagementSelectionCriteriaRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
use Worksome\RequestFactories\Concerns\HasFactory;

class UpdateIndividualCommunicationAndConsultationPreferencesRequest extends FormRequest
{
use ConditionallyRequireContactMethods;
use HasFactory;

public function authorize(): bool
{
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/UpdateIndividualConstituenciesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
use App\Enums\CommunityConnectorHasLivedExperience;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Worksome\RequestFactories\Concerns\HasFactory;

class UpdateIndividualConstituenciesRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return true;
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/UpdateIndividualRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
use Worksome\RequestFactories\Concerns\HasFactory;

class UpdateIndividualRequest extends FormRequest
{
use HasFactory;

/**
* Determine if the user is authorized to make this request.
*/
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/UpdateOrganizationConstituenciesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
use App\Enums\StaffHaveLivedExperience;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Worksome\RequestFactories\Concerns\HasFactory;

class UpdateOrganizationConstituenciesRequest extends FormRequest
{
use HasFactory;

public function authorize(): bool
{
return true;
Expand Down
Loading