PHPnews.io

Overview for 'sebastiandedeyne'


Non-reactive data in Alpine.js

Written by Sebastian De Deyne / Original link on Jun. 1, 2022

Sometimes you want to store data in your Alpine component without wrapping it in a JavaScript proxy (which is how Alpine keeps everything reactive). For example, third party libraries might have issues when wrapped in a proxy. Chart.js is one of those. If you store a Chart.js instance in Alpine dat…



Laravel Blade & View Models

Written by Sebastian De Deyne / Original link on Jan. 10, 2022

A view model represents data for a specific view or page. In its simplest form, a view model is a plain PHP object with a bunch of (typed) properties. class ProfileViewModel { public function __construct( public User $user, public array $companies, public string $action, ) {} } View models make the…



Eloquent findOrFail caveats

Written by Sebastian De Deyne / Original link on Nov. 23, 2021

I use Model::findOrFail a lot in Laravel. Recently, I realized it’s not always the best option. findOrFail is great because it ensures you’ll end up with a model instance. No more “Attempt to read property on null” exceptions. $title = Post::findOrFail($id)->title; Another benefit is that Larave…