-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Feat/show hide link #437
Conversation
There was a problem hiding this 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.
app/Livewire/Links/Index.php
Outdated
@@ -155,7 +173,14 @@ public function refresh(): void | |||
public function render(): View | |||
{ | |||
$user = User::query() | |||
->with(['links']) | |||
->with([ | |||
'links' => function (HasMany $query): HasMany { |
There was a problem hiding this comment.
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)
),
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe HasMany|Builder
There was a problem hiding this comment.
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
database/migrations/2024_07_23_055716_add_show_to_links_table.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Added show/hide link based guest, authentication user and current user