Laravel Blade & View Models
An overview on view models in Laravel
An overview on view models in Laravel
The other day I needed to sort a dataset in MySQL and ensure one value was always at the end. I never fully understood how order by
works, so I did some research on how to solve my problem and how order by
behaves.
I use Model::findOrFail
a lot in Laravel. Recently, I realized it's not always the best option.
Our Blink package is marketed as a caching solution to memoize data for the duration of a web request. Recently, we came upon another use case for the package: to execute something once and only once.
Today, we're launching a new Spatie package: Laravel Google Fonts. I've written about Google Fonts before. It's a great font catalog, but the service has it's downsides. First, fonts are hosted on a different domain than your app, so the browser needs to do an additional DNS lookup. Second, it's Google. Privacy-minded visitors might not appreciate the trip to Silicon Valley.
I've used HasOne
relationships for 1:1
relationships, but those are rare. I haven't considered using them to scope down relationships, like having one default payment method in a set of n
methods.
<?php class User extends Model{ public function paymentMethods(): HasMany { return $this->hasMany(PaymentMethod::class); } public function defaultPaymentMethod(): ?HasOne { return $this->hasOne(PaymentMethod::class) ->whereDefault(); }} $user->defaultPaymentMethod;
After reading Tim's post, I have a feeling there are some places where I needed this but didn't think of it at the time…
2021-03-29 #laravel #vite-with-laravel #frontend #build-tools
How to set up Inertia.js in Vite with Laravel.
2021-03-25 #laravel #vite-with-laravel #frontend #build-tools #react
How to set up React in Vite with Laravel.
2021-03-25 #laravel #vite-with-laravel #frontend #build-tools #typescript
How to set up TypeScript in Vite with Laravel.
2021-03-22 #laravel #vite-with-laravel #frontend #build-tools #blade
How to set up Tailwind CSS in Vite with Laravel.
2021-03-22 #laravel #vite-with-laravel #frontend #build-tools #tailwind
How to set up Tailwind CSS in Vite with Laravel.
2021-03-22 #laravel #vite-with-laravel #frontend #build-tools
I've had an eye on Vite for a while. With a stable release out the door (2.0, as 1.0 never left the release candidate stage) it seemed like a good time to give it a shot.
Vite is a frontend build tool like webpack. Instead of bundling development assets, Vite serves native ES modules transpiled with esbuild from the dev server. This means there's a lot less bundling to do, and results in a very fast developer experience. For production builds, Vite uses Rollup to bundle the assets.
2021-03-22 #laravel #vite-with-laravel #frontend #build-tools #vue
How to set up Vue.js in Vite with Laravel.
I created the original Spatie guidelines site three years ago. Last month, we consolidated a few of our subsites to our main spatie.be site, including the guidelines.
My colleague Ruben released a new Spatie package to generate type declarations in TypeScript from a Laravel application.