If you're using Laravel as a pure API and need to broadcast realtime events to your client with Laravel Websockets, this snippet covers using Laravel Echo in Vue to pick them up.
Forget the methods you've used before to generate random numbers and strings. PHP7 now supports it out the box!
Need to perform actions on models at a future date and time? This snippet covers scheduling a command to monitor when an action needs to happen, then dispatching a queued job to handle your action. This allows you to do things like set a blog post live at a given date and time, or whatever functionality you need similar to this. Plus, it's actually pretty easy to set up!
By adding a simple utility class to Tailwind, we can achieve beautiful gradient colors for headers (or any text).
Let's take a look at how to implement effortless drag and drop sortable functionality in Laravel Nova, with the help of two packages.
Want super smooth, fast infinite scrolling in Inertia? In this snippet, we'll seed our database with a bunch of data and start building the solution, refactoring along the way until we perfect it.
Sometimes we need to reference table names throughout our codebase, like when we're using the DB facade. Although table names don't change often, I still get an uneasy feeling hardcoding them. It's so much better to reference the model directly so we have one source of truth for the table name. So, let's learn how to do that! We'll also create a trait that allows static access to any of our model table names to keep our code a little tidier.
Building a trending list of content with Laravel is actually pretty easy. In this snippet, we’ll take a look at how to create a list of trending articles over time, gradually decaying less viewed articles and pushing popular articles to the top. You’ll also be able to adjust the decay levels, and update the frequency of decay to tweak how sensitive your trending content is and how ‘realtime’ it appears.
Want super smooth, fast infinite scrolling in Inertia? In this snippet, we'll seed our database with a bunch of data and start building the solution, refactoring along the way until we perfect it.
Adding SVGs to your Vue project doesn't need to be complicated. In this snippet, we'll take a look at using the vite-svg-loader package to make this a breeze, then clean things up by building our own component to handle loading SVGs effortlessly.
Pagination is essential for almost every application. Let's take a look at an easy way to render pagination links when using Inertia with Laravel and Vue.
If you're using Eloquent model observers, you'll know registering them can break your flow. How about a convenient trait to automatically hook up the associated observer? Let's build it!
If you're browser testing with Laravel Dusk, chances are you haven't not been able to verify that emails are being sent – that's because Dusk runs in a browser environment. In this video, we'll set Dusk up to test sending an email, and show you how to use Laravel email fakes (and a helpful package) to test that an email has been sent.
Need to perform actions on models at a future date and time? This snippet covers scheduling a command to monitor when an action needs to happen, then dispatching a queued job to handle your action. This allows you to do things like set a blog post live at a given date and time, or whatever functionality you need similar to this. Plus, it's actually pretty easy to set up!
Building an API? The Laravel Responsable interface is absolutely essential for keeping your response structure the same across your entire application.
Let's take a look at how to implement effortless drag and drop sortable functionality in Laravel Nova, with the help of two packages.
If your app has a form that auto-saves as the user types, you'll need to debounce your input to avoid too many requests being sent to your API. Let's look at a quick and easy way to debounce input in Vue 3 as our form data changes.
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!
To solve a potentially unlimited amount of nested items like categories, you need more than recursive Eloquent relationships. Let's figure out how to easily build a tree of items with a single query, and use recursive Blade components to output the result.
With a sprinkle of Alpine.js code, create a textarea that expands in height to fit content as a user types.
By default, Laravel Jetstream’s team functionality exposes the team ID on the client side. If you’d like to switch it up it for any reason, here’s how.
By default, Laravel Fortify’s email verification functionality exposes the user ID in the verification email link. If you’d like to switch it up it for any reason, here’s how.
Need to tinker with Laravel Jetstream routes? In this snippet, we’ll take a look at disabling the default routes and registering them in our project codebase instead.
Need to tinker with Laravel Fortify routes? In this snippet, we’ll take a look at disabling the default routes and registering them in our project codebase instead.
A quickstart guide to authenticating in Nuxt with a Laravel API using Sanctum. We’ll use the latest version of nuxt/auth, which includes native support for Sanctum as a provider.
If Tailwind doesn’t support an integration for where you want to use it, build with PostCSS! This snippet gets you set up for development and production.
By adding a simple utility class to Tailwind, we can achieve beautiful gradient colors for headers (or any text).
A Snackbar is a small notification bar that pops up when a user performs an action. In this snippet, we’ll build a simple Snackbar in Vue for when you don’t want to pull in a package to handle it for you.
Blade components are useful for re-usable parts of your app, but they also work really nicely as app layouts. This makes it really clean to define elements like page titles for each of your pages.
This snippet walks you through setting up a separate log channel in Laravel, with its own file. We'll also tap into a custom log formatter to choose the output structure. Great for separating different kinds of logs.
If you're using Laravel as a pure API and need to broadcast realtime events to your client with Laravel Websockets, this snippet covers using Laravel Echo in Vue to pick them up.
Here's how to implement a simple, clean pattern for infinite scrolling content in Vue. We'll refactor to make it more reusable, too.
Just for fun, let's build a simple RSS reader with Alpine.js that fetches and renders entries from a list of your chosen RSS publications.
You've got Sanctum up and running for authentication, but it's cookie based, so making requests to your API with Postman is a little more complicated. This snippet shows you how.
In some cases, autosizing a textarea height as a user types makes sense. Here's how to do it with Vue.
A low level overview of how middleware runs in your favourite framework. Starting with a simple app example, we'll build a middleware manager, add middleware to a stack, and run it.
Whoops gives you a much nicer way to display errors while you're building. In this snippet, we'll get Whoops installed with Slim 4.
Using mutators to set properties in your models can really clean up your code. In this snippet, we'll look at an example of automatic password hashing and see how much tidier our controllers end up.
A super quick guide to getting Tailwind installed, configured and working in a fresh Vue CLI project.
Two methods for setting Axios' base URL in your projects instead of using it directly from config.
New to Flutter state management with provider? This snippet explains the core concepts and sets you up to get working with it.
A quick start guide to getting Tailwind CSS working on your new or existing Nuxt projects.
Custom Laravel collections add another level of fluency to your code. Let's take a look at a couple of examples to get you started.
A quick setup guide for Vuelidate, a Vue inline validation library.
Need to send a notification to a group of users without looping in your controllers? Let's abstract this away and write some nice clean code.
Build a sticky navigation bar that automatically hides when a user scrolls the page, and reappears when they scroll back up.
Vue allows you to dynamically render components based on their names. This can help simplify your rendering and get rid of unnecessary logic from your templates. Here's an example using different notification types.
Some controllers have one action. What should you name that action? Turns out you don't even have to.
Using an .env file means keeping credentials out of your codebase and easily configurable between different environments. Doing this with Nuxt.js is easy as pie, let's check it out.
A quick tip that'll save you huge amounts of time if your app is heavily event driven. Define Laravel events and listeners, then have the classes automatically generated for you.
If you're chaining where methods when building queries with Eloquent, check out this simple refactoring tip.
If you need to register something within the boot() method of a model, here's a quick tip to do this within a trait if needed.
Here's how to use DigitalOcean spaces with Laravel's Filesystem. It's as easy as using S3!
You may have used the optional() helper in the Laravel framework before, but did you know about the optional callback?
By default, Laravel uses one key for route model binding lookup. When you need to use two or more, this is how to do it.
Let's walk through the Laravel tap() function, and how it might help clean up our code.
Ah, iteration. It's inevitable, so why not make it as clean as possible? We'll also dive into some of the complexities of looping in JavaScript.
If your models share a 'live' property that you control, why not refactor this down to a single unit of functionality?
A quick tip on globally registering all of your Vue components so you can just <Add /> them to your templates!
Setting up Laravel's filesystem to automatically separate user's uploads into their own directory.
Eloquent works nicely in Slim, but model observers outside of Laravel require a little bit more work.
Here's a popular pattern for diverging and dynamically calling a method based on an event, instantly cleaning up huge lists of conditionals.
You'll quickly outgrow the default Laravel structure as your app grows. Without much effort, let's look at some small changes that'll make a huge difference.
Allowing admins to sign in as other users is simple, but let's look at a more flexible and UX friendly solution.
A common problem when using HTTPS with Laravel is JavaScript and CSS assets breaking. In this snippet, we'll discuss a quick solution to fix that.
Database queues in Laravel are quick to set up and work well for most projects. Let's tidy things up, and pop the queue tables in a database of their own.
You might have used Laravel DebugBar to profile your query count and application speed, but how do we profile JSON responses? Let's find out!
Filters were removed from Vue.js 2.0. Here's a quick tip on keeping the same feel in your new Vue.js applications
Need to share a local project you're working on? Or test a webhook from a server? If you're using Laravel Homestead, we have you covered with this quick tip.
Need to share a local project you're working on? Or test a webhook from a server? We have you covered with this quick tip.
Do you store sensitive information directly in your code? That's fine for development, but if you're pushing to source control or production, there's better way.
Forget the methods you've used before to generate random numbers and strings. PHP7 now supports it out the box!
You might need to change the way your Laravel pagination links are displayed. Well, here's how.
Covering what referential integrity is, and how easy it is to enforce this to ensure tidy tables with integrity between relationships.
Tidy up your code drastically by binding models to routes and automatically fetching a model by it's primary key when you access a URI like /users/1.
Interfaces are used in development a lot, but why make a class adhere to an defined interface? Let's take a look at an example of how this is useful.
Easily set up powerful, flexible configuration within Slim 3 and make it easier to switch your application settings.
A useful tip for when you need to quickly cast an array to an object.
How ternery operators can clean up your code and speed up development.
Did you know PHP has a built-in web server we can run from the command line? Let's take a look at how it works.
A couple of methods you can use to flatten a multidimensional array with PHP. The first method looks at a more verbose method of looping through array items and self calling a function/method, and the second looks at using standard PHP classes to make it a bit cleaner.
Speed up development and use Faker to generate fake data, like words, paragraphs, names, email addresses, and so much more! Here, we look at seeding a database with 100 records of data at the click of a button.
Ever wanted to run a command to check your code against a particular standard? PHP CodeSniffer lets you do that right from the command line!
Learn how to dramatically speed up your workflow by generating large amounts of HTML using CSS style selectors. In this video, we specifically look at generating HTML, but Emmet offers other functionality to help you work faster.