Skip to main content

spatie/freek.dev

650 stars
2 code files
View spatie/freek.dev on GitHub

app/View/Components/SeriesNextPostComponent.php

Open in GitHub
use App\Models\Post;
use Illuminate\View\Component;
 
class SeriesNextPostComponent extends Component
{
public function render()
{
$nextPost = Post::query()
->where('series_slug', $this->post->series_slug)
->where('id', '>', $this->post->id)
->orderBy('id')
->first();
 
return view('components.series-next-post-component', compact('nextPost'));
}
}

resources/views/components/series-next-post-component.blade.php

Open in GitHub
@if ($nextPost)
This series is continued in <a href="{{ route('post', $nextPost->slug) }}">{{ lcfirst($nextPost->series_toc_title) }}</a>.
@endif