Snippets

Clear orderBy in Laravel

Playing
Clear orderBy in Laravel
4 mins1 year ago

If you've already applied ordering to an Eloquent query, you'll have to 'reset' it if you need to change the order later on. Here's how!

Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.

Suggested courses

Laravel

Logging Unique Views in Laravel with Redis

If you need to log unique views in Laravel, you might reach for a database table to track IP addresses or another unique piece of data. Let's take a look at speeding things up both in performance and complexity by using Redis and the HyperLogLog probabilistic data structure. Once we're done, we'll set up a period command to sync views back to the database for easy ordering, and then create a trait to share functionality between other models.

4 episodes
22 mins
Laravel

Dropdown Autocomplete Search Anything in Laravel

Using the power of Laravel Scout and Meilisearch, let’s build an instant dropdown search in your Laravel apps. We’ll start with the basics of indexing data, then use the JavaScript autocomplete library to instantly show results as the user types — even multiple sources at the same time!

12 episodes
1 hr 3 mins
Laravel

Translations with Laravel and Inertia

Localisation is a breeze in Laravel applications, but what happens when you need to bring this to the client-side? Turns out in Inertia, it's pretty simple. In this course, we'll build a language switcher, share translations with the client, and build a simple translation helper for Vue to use directly in templates. We'll also cover caching translations to keep things running smoothly. The best part? With the magic of reactivity, we'll be able to switch languages without any page refresh, and see everything instantly translated.

9 episodes
57 mins
Laravel

Liking Things in Laravel with Redis

Let’s skip the database and build the ability to like any model in Laravel, using Redis. Traditionally you’d reach for the database for this kind of thing, but as you load more models and start performing checks within relationships — things begin to slow down. With a key-value store like Redis, tracking users who have liked comments (or anything) keeps everything ridiculously fast.

6 episodes
21 mins
Laravel

Build A Static File Blog with Laravel

Let's build a ridiculously fast blog from scratch in Laravel, entirely driven by markdown files. No database required! Your blog will feature everything you're used to, like syntax highlighting, post tagging and pagination. Plus, it'll render in record time. Once you're done with the course, you'll be able to add on additional features with ease, style it up how you want and quickly create new posts since there's no need for an admin panel.

13 episodes
1 hr 11 mins