marick / laravel-mysql-enhanced
Add support for lateral joins and more in MySQL for Laravel
Fund package maintenance!
marickvantuil
Requires (Dev)
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0
README
The package currently only adds support for lateral joins because is something I needed. The idea is similar to Tobias Petry's amazing package: Laravel Postgres Enhanced.
Feel free to make a PR to add more features.
Installation
composer require marick/laravel-mysql-enhanced
Features
Lateral joins
Available methods: joinSubLateral
, leftJoinSubLateral
User::select('users.email', 'posts.*') ->joinSubLateral( Post::whereColumn('posts.user_id', 'users.id') ->orderBy('price', 'desc') ->limit(3), 'posts', )
SELECT users.email, posts.* FROM users INNER JOIN LATERAL ( SELECT * FROM posts WHERE posts.user_id = users.id ORDER BY price DESC LIMIT 3 ) as posts on true