Skip to content

marickvantuil/laravel-mysql-enhanced

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enhance MySQL for Laravel with new features

Latest Version on Packagist Tests Total Downloads

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