Skip to content
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
4 changes: 2 additions & 2 deletions app/Http/Controllers/ArticlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function show(Article $article): View
/** @var User $user */
$user = Auth::user();

views($article)->record();
views($article)->cooldown(now()->addHours(2))->record();
Copy link
Member

Choose a reason for hiding this comment

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

Que résoud cette action et quel comportement tu reçois et comment devrait-il normalement se comporter

Copy link
Author

Choose a reason for hiding this comment

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

views($article)->record();
la première ligne comptabilise chaque vue sans restriction, tandis que views($article)->cooldown(now()->addHours(2))->record(); impose une attente de 2 heures entre les enregistrements de vues pour le même article.

Copy link
Member

Choose a reason for hiding this comment

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

Si 50 personnes regardent l'article au bout de 10 minutes il n'enregistre pas les 50 records ? Ou tu dis qu'il va enregistrer les 50 records après 2h

Copy link
Author

Choose a reason for hiding this comment

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

Non c'est pour dire que un utilisateur ne pourrait voir le post deux fois de suite, genre sa vue sera mis en cache de tel sorte que si il voit un poste, en actualisant le navigateur, on considérera que il a déjà vu le post , la le nombre de vue ne sera pas incrémenté cela pendant les deux prochaines heures. donc la vue de post par cette utilisateur sera gelée.


/** @var Article $article */
$article = Cache::remember('post-'.$article->id, now()->addHour(), fn () => $article);
Expand Down Expand Up @@ -66,4 +66,4 @@ public function edit(Article $article): View

return view('articles.edit', compact('article'));
}
}
}
4 changes: 2 additions & 2 deletions app/Http/Livewire/Discussions/AddComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public function saveComment(): void
->duration(5000)
->send();

$this->reset();
$this->reset('body');
Copy link
Member

Choose a reason for hiding this comment

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

C'est la même chose. Le reset réinitialise toutes les variables du formulaire

}

public function render(): View
{
return view('livewire.discussions.add-comment');
}
}
}
2 changes: 1 addition & 1 deletion resources/views/articles/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<div>
<h2 class="text-xs leading-5 font-medium tracking-wide uppercase text-skin-base">Article suivant</h2>
<a href="{{ route('articles.show', $next) }}" class="mt-3 flex items-start space-x-2">
<img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') }}" alt="{{ $next->slug }}">
<img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'">
<span class="text-sm font-medium leading-4 text-skin-inverted hover:text-skin-primary-hover line-clamp-2">{{ $next->title }}</span>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{!! $article->excerpt(175) !!}
</p>
<div class="relative h-96 overflow-hidden">
<img class="w-full h-full object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" />
<img class="w-full h-full object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}">
</div>
<div class="flex justify-between space-x-8">
<div class="flex space-x-6">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/articles/card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<a href="{{ route('articles.show', $article) }}" class="group">
<div class="aspect-w-3 aspect-h-2">
<img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" />
<img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}">
</div>
</a>
<div
Expand Down
3 changes: 1 addition & 2 deletions resources/views/components/articles/overview.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<div class="aspect-w-3 aspect-h-2">
<img class="object-cover shadow-lg rounded-lg group-hover:opacity-75"
src="{{ $article->getFirstMediaUrl('media') }}"
alt="{{ $article->title }}"
/>
alt="{{ $article->title }}">
</div>
</a>
<div class="sm:col-span-2">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/livewire/articles/_form.blade.php
Copy link
Member

Choose a reason for hiding this comment

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

@jiordiviera ce que je dis souvent c'est que si un fichier n'entre pas dasn le scope de ta tache faudrait éviter de les modifier. Parce que tu modifies ce fichier pourtant ta feature n'a pas besoin de le faire.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{ __('Enregistrer') }}
</button>
<span x-data="{ open: false }" @keydown.escape.stop="open = false;" @click.away="open = false" class="-ml-px relative block">
<button type="button" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-transparent text-sm font-medium text-white text-white bg-green-600 hover:bg-green-700 focus:z-10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-body focus:ring-green-500"
<button type="button" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-transparent text-sm font-medium text-white bg-green-600 hover:bg-green-700 focus:z-10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-body focus:ring-green-500"
id="option-menu-button"
x-ref="button"
@click="open = !open"
Expand Down Expand Up @@ -253,7 +253,7 @@ class="flex items-center justify-center text-sm leading-none text-center rounded
wire:model="title"
name="title"
id="title"
class="block w-full h-auto px-0 py-4 text-3xl sm:text-4xl font-bold placeholder-skin-input focus:placeholder-skin-input-focus font-normal text-skin-inverted bg-transparent border-0 leading-normal border-0 appearance-none focus:ring-0 shadow-none"
class="block w-full h-auto px-0 py-4 text-3xl sm:text-4xl font-bold placeholder-skin-input focus:placeholder-skin-input-focus font-normal text-skin-inverted bg-transparent leading-normal border-0 appearance-none focus:ring-0 shadow-none"
placeholder="Titre de votre article..."
autofocus
autocomplete="off"
Expand Down
Loading