9
๐ฅ You can use partial Queue fakes
#Laravel Tip: Since todays Laravel 9.5 release you can now do partially queue faking.
๐ฅ This week's code tips for Laravel developers
A weekly thread ๐งต
9
#Laravel Tip: Since todays Laravel 9.5 release you can now do partially queue faking.
8
Within your Pest / PHPUnit tests, you may use @laravelphp's "mock" method to instruct the container to use your mocked instance of the object instead of constructing the object itself. โ
7
๐ฅ Want to have some autocompletion in Blade?
You can just add a doc block ๐
#laravel #php
6
๐กDid you know you can write abstract methods in a trait?
This way you don't have to make assumptions about the models where the trait is used.
But instead, you have a clear contract:
5
One of my favorite things about using S3 in PHP is that you can register a stream wrapper to interact with files.
You can use the native PHP functions like fopen, fread, etc.
Very helpful when you have massive files you don't want to load into memory!
(CSVs are a use case.)
4
๐ฅ #Laravel Query Time Casting
We all know you can add casts to your eloquent models, but did you know you can add casts to a specific query?
3
โก๏ธ Database Tip
Your application will have bugs and any data stored may be corrupt forever. But with constraints on the data model, rules would have prevented saving incorrect data in the first place! Use them as a last frontier to make sure you always have valid data.
2
I had no idea that you could pass data into Laravel responses using with{Variable} magic methods! I kind of like this way a little better...
1
Calling pluck directly on a model is the most performant way to retrieve a single column from all models in Laravel. Calling get/all before pluck will read all models into memory before plucking the value.
We're writing a book, you can get it for free here. We're writing a book! Join the early access to get it for free.