Giter Club home page Giter Club logo

Comments (4)

fico7489 avatar fico7489 commented on June 28, 2024

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 :

laravel/framework#22382

😄

from laravel-eloquent-join.

dariusj18 avatar dariusj18 commented on June 28, 2024
  1. Yeah, I prefer it that way too, but using the method name is more Laravely.

  2. 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

  3. Excellent, makes sense.

from laravel-eloquent-join.

fico7489 avatar fico7489 commented on June 28, 2024

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.

fico7489 avatar fico7489 commented on June 28, 2024

If you have more questions or suggestion feel free to ask me

from laravel-eloquent-join.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.