The first thing you should do when starting any new Laravel app

preview_player
Показать описание
Laravel provides a Model::shouldBeStrict() method that will throw an exception when any of the following happens:

1. When you attempt to lazy load relationships (preventing N+1 query issues)
2. Prevents Silently Discarding Attributes
3. Prevents Accessing Missing Attributes on your models

It's simple yet powerful and great way to keep your code in check as you build out a new project.

----------------------------------------------------------------------
JOIN OUR WEEKLY LARAVEL NEWSLETTER
----------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Awesome way to start a Laravel project, will definitely start implementing this on all my new Laravel projects.
Thanks for sharing ❤

chiagozieokafor
Автор

Great 👌, I'll use this on my apps

ndumisani
Автор

Great tip, excellent explanation of it's purpose, I believe in catching errors early.

askadj
Автор

I use lambo to install my Laravel apps. It comes with an after file so that the stuff I always install gets installed without me having to think about it. This includes installing TailwindCSS, adding ShouldBeStrict, laravel-query-detector, Pest, Blueprint, as well as some macros I often use and my bladeImageCrop package. It also inits a git file and sets up some stubs.

DNABeast
Автор

Awesome/effective tip, man. Thanks for that.

AfmpJR
Автор

Good feature, i will use it on next project

artemperehonov
Автор

What code editor u use? it look so clean

babypsycho
Автор

Had no idea about this feature! Going to turn this on in my app

davidharting
Автор

just have in mind that when doing Test and you factory() class and your factory do not set values from nullable fields you will get exception when trying to access any nullable property that is not set in the factory class

steenrabol
Автор

When you've designed it wrong and now try to fix it with crutches 😂

kinvain