Using Eloquent's firstOr
You know `firstOrFail`, `firstOrCreate`, etc in @laravel
— Jeff Madsen (@codebyjeff) May 19, 2019
There's also a simple `firstOr` that will run a callback if not found pic.twitter.com/q7QmPR1y1S
Read more [twitter.com]
You know `firstOrFail`, `firstOrCreate`, etc in @laravel
— Jeff Madsen (@codebyjeff) May 19, 2019
There's also a simple `firstOr` that will run a callback if not found pic.twitter.com/q7QmPR1y1S
Read more [twitter.com]
Jonathan Reinink wrote another awesome post on how to handle a complicated query.
I was asked recently how to calculate multiple totals (aggregates) in Laravel in the most efficient way. For example, maybe you have an email subscription service and want to display various totals based on your subscribers
Read more [reinink.ca]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
At the Clarabridge Developers blog, Toon Daelman wrote a good post on how to improve your exceptions.
You've made it to this post thinking "Why do we still need to talk about Exceptions?". Well, they're used everywhere in OOP codebases, but sometimes they're used in a way that make debugging a bit difficult. Let's look at some ways to make debugging exceptions a bit more fun!
Read more [engagor.github.io]
? PSA: <title> tags matter (especially for people browsing the web with screen readers)
— Caleb Porzio (@calebporzio) May 28, 2019
ICYMI: https://t.co/g7IdUkEjiQ pic.twitter.com/ANIjMZUMDN
Read more [twitter.com]
? Laravel quick tip
— Sebastian De Deyne (@sebdedeyne) May 21, 2019
Use ->map->only on Eloquent collections to pluck multiple attributes pic.twitter.com/z3c1sOox9J
Read more [twitter.com]
In this video Jason McCreary creates a PR that adds a null driver to our laravel-newsletter package.
In a new blogpost, Sebastian De Deyne compares Vue syntax with React syntax.
This post is a succinct rundown of most Vue features, and how I would write them with React in 2019 with hooks.
Read more [sebastiandedeyne.com]
When a request comes in your app will return a response. To create that response, your application has to do some work. Most likely queries will execute. This all takes some time. Wouldn't it be nice if the same request comes in, we can return the response the application has constructed previously?
laravel-validation-rules is a package that contains handy custom validation rules that are being used in various client projects we made at Spatie. Last week I added a new validate rule called Delimited to the package.
In this blog post, I'd like to explain why we added it and how it can be used.
In an awesome post, my colleague Brent explains that PHP is in a very good state nowadays. If you dismissed the language previously, now is a good time to take another look.
PHP managed to evolve quite a bit since the 5.* days. Today I'm addressing the people who are either not programming in PHP anymore, or are stuck in legacy projects.
Read more [stitcher.io]
Matt Allan explains why using an offset is slow when used on large datasets.
It turns out it’s easy to page through results without using offset. All we have to do is keep track of the last ID we saw, then filter the results so we only fetch rows we haven’t seen.
Read more [mattallan.me]
On his blog, Mathias Verraes started a series of posts on patterns for decoupling in distributed systems. I'll link to just one of the posts here, but they're all worth your time.
The mind switch is to think of the passage of time as just another Domain Event, exactly like all the other events. After all, if we define a Domain Event as a granular point in time where something happened that is relevant to the business, then certainly the next business day, month, or quarter, is extremely relevant.
Read more [verraes.net]
Senior CEO Frederick Vanbrabant helps you to answer this horrible interview question.
You have probably already heard the horror stories of code interviews where they ask you to reverse a binary tree on a whiteboard. (if not check this blog post that I profoundly disagree with). Well, a few days ago I was in that exact situation. And I had no idea what the interviewer was talking about. So what are these binary trees and why is it so critical that you know how to inverse them? Let’s find out.
Read more [frederickvanbrabant.com]
Recently Laravel introduced a Tappable trait. This blogpost explains what this trait allows you to do.
As you might know, the Laravel framework comes with a handy tap method which allows you to call the given closure with the given value and then return the value. Sounds confusing? It probably is until you've seen it!
Read more [protone.media]
Hooks is feature was added recently to React that I really like.
In this article, we reintroduce closures by building a tiny clone of React Hooks. This will serve two purposes – to demonstrate the effective use of closures, and to show how you can build a Hooks clone in just 29 lines of readable JS. Finally, we arrive at how Custom Hooks naturally arise.
Read more [www.netlify.com]
In the latest episode of Full Stack Radio podcast, my colleague Seb explains the differences between React and Vue.
In this episode, Adam talks to Sebastian De Deyne about learning React from the perspective of a Vue developer, and how to translate all of the Vue features you're already comfortable with to React code.
Read more [www.fullstackradio.com]
My colleague Brent started a new podcasts series called "Rant with Brent". In the first episode has explains why he likes the "final" keyword in PHP.
I'm giving podcasting a try. Let me know what you think of it via Twitter or e-mail. You can download the episode here. In this episode I talk about why I think final helps you write better maintainable code.
Read more [stitcher.io]
Emily Shaffer makes the case for commenting regular expressions.
It’s probably not a good idea to encourage your coworkers to think critically about what life would be like if you got hit by a bus, but the good news is that you can simultaneously document your regular expression and teach your coworkers some regex basics, if you comment them carefully!
Read more [nasamuffin.github.io]
In a new post at the Oh Dear blog, there's a good explanation how HSTS improves security.
HSTS stands for HTTP Strict Transport Security. It's a mechanisme that allows a website to signal that it should only be reached via HTTPS - the encrypted HTTP - instead of the plain text HyperText Transfer Protocol.
Read more [ohdear.app]
Over at Laravel News, Paul Redmond published a good way to test streamed responses.
Read more [laravel-news.com]