Comments (4)
1.yes 3.* is not backward compatible, because of this I named it 3.* not 2.*
I don't want to supports < 5.5 anymore
By my opinion I think that is better to pass join type in parameter rather that use 3 different methods
2.I have in plan also to support HasMany relation, method for join should be something like this
public function orderByJoin($column, $sortBy = 'asc|desc', $joinType = 'left|inner|cross', $sortTypeJoin = 'id', $sortByJoin = 'asc')
3.orderByJoinPivot can be usefull also, but this method is for pivot table on HasMany relation
4.group by is not needed anymore because I added this https://github.com/fico7489/laravel-eloquent-join/blob/master/src/EloquentJoinBuilder.php#L101
maybe I can allow user from choose between this new way or group by
5.Extending laravel relations are awkward, acctually I requested that improvement :
😄
from laravel-eloquent-join.
-
Yeah, I prefer it that way too, but using the method name is more Laravely.
-
The issue I see with either method is it's kind of an unexpected behavior. It also doesn't give you the option to determine which records to get, with your subquery there is no ordering, so there is nothing giving the user the ability to determine which is the top record, it leaves that up to the database and how it decides to store records. This is at it's root is an issue with Eloquent and how it assumes one row per record when hydrating models
-
Excellent, makes sense.
from laravel-eloquent-join.
2.hm yeah I really didn't finished concept but it will be roughly something like this :
order by related table
//order products by units name (subquery will get first unit asc by name)
Products::orderByJoin('units.name', 'asc', 'left', 'name', 'asc')
//order products by units name (subquery will get last unit asc by name)
Products::orderByJoin('units.name', 'asc', 'left', 'name', 'desc')
//order products by units name (subquery will get first unit asc by id)
Products::orderByJoin('units.name', 'asc', 'left', 'id', 'desc')
//order products by units name (subquery will get first unit asc by min id)
Products::orderByJoin('units.name', 'asc', 'left', 'value', 'id', 'min')
order by pivot table
Products::orderByJoinPivot('units.value', 'asc', 'left', 'value', 'asc', 'min')
Products::orderByJoinPivot('units.value', 'asc', 'left', 'value', 'asc', 'max')
tables
products
id|name|shop_id
units
id|name
product_unit
id|product_id|unit_id|value
from laravel-eloquent-join.
If you have more questions or suggestion feel free to ask me
from laravel-eloquent-join.
Related Issues (20)
- wrong attribute value HOT 3
- Join multiple relationships by calling the joinRelations method once HOT 4
- Problem when joining the same table multiple times HOT 3
- Class `DB` not found HOT 2
- LoadCount not support HOT 1
- supports laravel 8? HOT 1
- OrderByJoin for BelongsTo relationships breaks in laravel 5.5 HOT 1
- Optional Group by
- Blockchain/E-currency software
- Count without first calling ->get() always returns 1
- Laravel 9, all test fail, not sure how to fix those errors but i have updated the dependencies to illuminati 9 and run your tests this is the result.
- Laravel 9 HOT 5
- Support laravel 10 HOT 1
- Aggregate parameters are not escaped HOT 2
- Syntax error or access violation: 1055 '...' isn't in GROUP BY HOT 1
- Error when applying sort by join on MSSQL DB HOT 3
- Column not found: 1054 Unknown column 'sort' in 'order clause'
- Question: Why is this not the default in Eloquent? HOT 2
- Question: Eager loading HOT 5
- Laravel 7.x - Cannot install HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-eloquent-join.