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/show hide link #437

Merged
merged 6 commits into from
Jul 24, 2024
Merged

Feat/show hide link #437

merged 6 commits into from
Jul 24, 2024

Conversation

Akhmami
Copy link
Contributor

@Akhmami Akhmami commented Jul 23, 2024

Added show/hide link based guest, authentication user and current user

@Akhmami Akhmami requested a review from nunomaduro July 23, 2024 08:54
Copy link
Collaborator

@CamKem CamKem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting feature, a few comments / improvements.

@@ -155,7 +173,14 @@ public function refresh(): void
public function render(): View
{
$user = User::query()
->with(['links'])
->with([
'links' => function (HasMany $query): HasMany {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can utilise the when() method here to run the conditional inline & apply the callback.

For example:

            ->with([
                'links' => fn (HasMany $query): HasMany => $query
                    ->when(
                        auth()->id() !== $this->userId,
                        fn (Builder $query): Builder => $query
                            ->where('show', true)
                    ),
            ])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe HasMany|Builder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can utilise the when() method here to run the conditional inline & apply the callback.

For example:

            ->with([
                'links' => fn (HasMany $query): HasMany => $query
                    ->when(
                        auth()->id() !== $this->userId,
                        fn (Builder $query): Builder => $query
                            ->where('show', true)
                    ),
            ])

this looks better

app/Livewire/Links/Index.php Outdated Show resolved Hide resolved
resources/views/components/icons/eye-slash.blade.php Outdated Show resolved Hide resolved
resources/views/components/icons/eye.blade.php Outdated Show resolved Hide resolved
Copy link
Contributor Author

@Akhmami Akhmami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed overflow-hidden because truncate was already available in the

tag, and move h-12 to parent div.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will persistent the link description element centered

@nunomaduro nunomaduro merged commit aed6893 into main Jul 24, 2024
@nunomaduro nunomaduro deleted the feat/show-hide-link branch July 24, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants