

GitHub - reinink/advanced-eloquent: A set of advanced Eloquent macros for Larave...
source link: https://github.com/reinink/advanced-eloquent
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

readme.md
Advanced Eloquent
A set of advanced Eloquent macros for Laravel.
Installation
You can install this package via Composer:
composer require reinink/advanced-eloquent
This package uses auto-discovery, so there is no further configuration required.
API
This package currently provides three Eloquent\Builder
macros for working with subqueries in Laravel.
addSubSelect($column, $query)
orderBySub($query, $direction = 'asc', $bindings = [])
orderBySubDesc($query, $bindings = [])
Examples
Get a user's last login date using a subquery:
$users = User::addSubSelect('last_login_at', Login::select('created_at') ->whereColumn('user_id', 'users.id') ->latest() )->get();
Order users by their company name using a subquery:
$users = User::orderBySub(Company::select('name')->whereColumn('company_id', 'companies.id'))->get();
Recommend
-
55
laracon2018 - Source code for my example app used in my Laracon Online 2018 talk
-
32
readme.md Client-side rendering in laravel This is a demo app to suppliment my
-
41
readme.md Laracon US 2019 1. Implement view policy Add new user policy (php artisan make:policy UserPolicy)
-
11
Advanced Laravel models filtering capabilities Installation You can install the package via composer: composer require pricecurrent/laravel-eloquent-filters Usage This package gives you...
-
12
Form Hell Part 2: Complex Validation Full Stack Radio
-
10
Rebuilding a SaaS with Vue.js and Tailwind CSS Full Stack Radio
-
6
Client-Side Rendering, Server-Side Routing Full Stack Radio
-
7
Fixing Common API Design Mistakes Full Stack Radio ...
-
9
Add Likes, Bookmarks, Favorites, and Other Marks in your Application With Laravel Markable Laravel Markable is a package to Integrate likes, bookmarks, favorites, reactions,...
-
11
Last time I’ve been analyzing the performance of Laravel’s container. I’ve encountered that the application spends a lot of time building dependencies, especially for heavy endpoints. That was strange because I would rather expect the relevant log...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK