When using a simple statement for creating an entry in a DB:
Post::create(['title_TYPO_HERE' => 'My awesome title']);
This will actually create a post with title = null
(let's assume it's nullable)
How to make Eloquent fail in such cases to prevent typos?
what you are looking for seems to be: (https://laravel.com/docs/11.x/eloquent#configuring-eloquent-strictness)
class AppServiceProvider
{
public function boot(): void
{
Model::preventSilentlyDiscardingAttributes(! $this->app->isProduction());
}
}