diff --git a/app/Http/Controllers/ArticlesController.php b/app/Http/Controllers/ArticlesController.php index 2b440c31..b5722c32 100644 --- a/app/Http/Controllers/ArticlesController.php +++ b/app/Http/Controllers/ArticlesController.php @@ -27,6 +27,7 @@ public function show(Article $article) views($article)->record(); + /** @var Article $article */ $article = Cache::remember('post-'.$article->id, now()->addHour(), fn () => $article); abort_unless( @@ -34,13 +35,14 @@ public function show(Article $article) 404 ); + $image = $article->getFirstMediaUrl('media') ?? asset('images/socialcard.png'); seo() ->title($article->title) ->description($article->excerpt(100)) - ->image($article->getFirstMediaUrl('media')) + ->image($image) ->twitterTitle($article->title) ->twitterDescription($article->excerpt(100)) - ->twitterImage($article->getFirstMediaUrl('media')) + ->twitterImage($image) ->twitterSite('laravelcm') ->withUrl(); diff --git a/app/Http/Livewire/Articles/Edit.php b/app/Http/Livewire/Articles/Edit.php index 67fe6d49..9ff0f16e 100644 --- a/app/Http/Livewire/Articles/Edit.php +++ b/app/Http/Livewire/Articles/Edit.php @@ -7,6 +7,7 @@ use App\Models\User; use App\Traits\WithArticleAttributes; use App\Traits\WithTagsAssociation; +use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; use Livewire\Component; @@ -38,19 +39,19 @@ public function mount(Article $article) $this->associateTags = $this->tags_selected = old('tags', $article->tags()->pluck('id')->toArray()); } - public function submit() + public function submit(): void { $this->alreadySubmitted = $this->article->submitted_at !== null; $this->submitted_at = $this->article->submitted_at ?? now(); $this->store(); } - public function store() + public function store(): void { $this->save(); } - public function save() + public function save(): void { $this->validate(); @@ -80,7 +81,7 @@ public function save() $this->redirectRoute('articles.show', $this->article); } - public function render() + public function render(): View { return view('livewire.articles.edit', [ 'tags' => Tag::whereJsonContains('concerns', ['post'])->get(), diff --git a/app/Models/Article.php b/app/Models/Article.php index 2e99ef8e..21889514 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -207,7 +207,7 @@ public function isPublished(): bool public function isNotPublished(): bool { - return ($this->isNotSubmitted() || $this->isNotApproved()) && $this->published_at === null; + return $this->isNotSubmitted() || $this->isNotApproved(); } public function isPinned(): bool diff --git a/resources/views/articles/show.blade.php b/resources/views/articles/show.blade.php index 8e6d9564..53a610e3 100644 --- a/resources/views/articles/show.blade.php +++ b/resources/views/articles/show.blade.php @@ -14,7 +14,7 @@
Vous aimez cet article ? Faite le savoir en partageant
+{{ __('Vous aimez cet article ? Faite le savoir en partageant') }}