Skip to content

fix(LAR-73): failed tests #159

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

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions app/Actions/Replies/CreateReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
use App\Models\Reply;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Lorisleiva\Actions\Concerns\AsAction;

final class CreateReply
{
use AsAction;

public function handle(string $body, User $user, Model $model): Reply
{
$reply = new Reply(['body' => $body]);
Expand Down
6 changes: 2 additions & 4 deletions app/Actions/Replies/LikeReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
use App\Models\Reaction;
use App\Models\Reply;
use App\Models\User;
use Lorisleiva\Actions\Concerns\AsAction;

final class LikeReply
{
use AsAction;

public function handle(User $user, Reply $reply, string $reaction = 'love'): void
{
$react = Reaction::where('name', $reaction)->first();
/** @var Reaction $react */
$react = Reaction::query()->where('name', $reaction)->first();

$user->reactTo($reply, $react);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Livewire/Discussions/AddComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Discussion;
use Filament\Notifications\Notification;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;

final class AddComment extends Component
Expand All @@ -32,7 +33,7 @@ public function saveComment(): void
['body.required' => __('Votre commentaire ne peut pas être vide')]
);

$comment = CreateReply::run($this->body, auth()->user(), $this->discussion);
$comment = app(CreateReply::class)->handle($this->body, Auth::user(), $this->discussion); // @phpstan-ignore-line

$this->dispatch('$refresh')->self();

Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Discussions/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function toggleLike(): void
return;
}

LikeReply::run(auth()->user(), $this->comment);
app(LikeReply::class)->handle(auth()->user(), $this->comment); // @phpstan-ignore-line

$this->dispatch('reloadComment')->self();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/MarkdownX.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function upload(array $payload): void
@[, $file_data] = explode(',', $file_data);
$type = explode('/', $type)[1];

if ( ! in_array($type, config('markdownx.image.allowed_file_types'))) {
if (! in_array($type, config('markdownx.image.allowed_file_types'))) {
$this->dispatch('markdown-x-image-uploaded', [
'status' => 400,
'message' => 'File type not supported. Must be of type '.implode(', ', config('markdownx.image.allowed_file_types')),
Expand Down
5 changes: 2 additions & 3 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ public static function findOrCreateSocialUserProvider(SocialUser $socialUser, st
'name' => $socialUser->getName() ?? $socialUser->getNickName() ?? $socialUser->getId(),
'email' => $socialEmail,
'username' => $socialUser->getNickName() ?? $socialUser->getId(),
'github_profile' => 'github' === $provider ? $socialUser->getNickName() : null,
'twitter_profile' => 'twitter' === $provider ? $socialUser->getNickName() : null,
'github_profile' => $provider === 'github' ? $socialUser->getNickName() : null,
'twitter_profile' => $provider === 'twitter' ? $socialUser->getNickName() : null,
'email_verified_at' => now(),
'avatar_type' => $provider,
]);
Expand Down Expand Up @@ -425,7 +425,6 @@ public function scopeMostSolutionsInLastDays(Builder $query, int $days): Builder
* Scope for most submissions in the last days.
*
* @param Builder<User> $query
* @param int $days
* @return Builder<User>
*/
public function scopeMostSubmissionsInLastDays(Builder $query, int $days): Builder
Expand Down
150 changes: 1 addition & 149 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ parameters:
- app/Markdown/MarkdownHelper.php
ignoreErrors:
- "#^Cannot access property \\$transaction on array\\|object\\.$#"
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
- identifier: missingType.iterableValue
- identifier: missingType.generics
8 changes: 4 additions & 4 deletions resources/views/livewire/articles/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class="flex items-center pl-3 font-sans text-base font-medium text-gray-500 dark
</div>
<div class="mt-3 flex items-center space-x-2 sm:mt-0">
@hasanyrole('admin|moderator')
<x-button type="button" wire:click="store">
<x-buttons.primary type="button" wire:click="store">
<x-loader class="text-white" wire:loading wire:target="store" />
{{ isset($article) ? __('Enregistrer') : __('Publier') }}
</x-button>
</x-buttons.primary>
@else
@if (isset($article))
<span class="relative z-20 inline-flex rounded-md shadow-sm">
Expand Down Expand Up @@ -98,10 +98,10 @@ class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:text-gray-
</span>
</span>
@else
<x-button type="button" wire:click="submit">
<x-buttons.default type="button" wire:click="submit">
<x-loader class="text-white" wire:loading wire:target="submit" />
{{ __('Enregistrer') }}
</x-button>
</x-buttons.default>
@endif
@endhasanyrole

Expand Down
4 changes: 3 additions & 1 deletion resources/views/livewire/articles/create.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<div>
@include('livewire.articles._form')
<div>
@include('livewire.articles._form')
</div>
</div>
4 changes: 2 additions & 2 deletions resources/views/livewire/discussions/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class="mt-2"

<div class="border-t border-skin-base pt-5">
<div class="flex justify-end">
<x-button type="button" class="inline-flex" wire:click="store">
<x-buttons.primary type="button" class="inline-flex" wire:click="store">
<x-loader class="text-white" wire:loading wire:target="store" />
Enregistrer
</x-button>
</x-buttons.primary>
</div>
</div>
</div>
6 changes: 5 additions & 1 deletion resources/views/livewire/discussions/create.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div>
@include('livewire.discussions._form')
<div>
<div>
@include('livewire.discussions._form')
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions resources/views/livewire/forum/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class="font-medium text-primary-600 underline hover:text-primary-600-hover"

<div class="border-t border-skin-base pt-5">
<div class="flex justify-end">
<x-button type="button" class="inline-flex" wire:click="store">
<x-buttons.primary type="button" class="inline-flex" wire:click="store">
<x-loader class="text-white" wire:loading wire:target="store" />
Enregistrer
</x-button>
</x-buttons.primary>
</div>
</div>
</div>
Loading