Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latestOfMany() doesnt work #3231

Open
masterbater opened this issue Dec 22, 2024 · 1 comment
Open

latestOfMany() doesnt work #3231

masterbater opened this issue Dec 22, 2024 · 1 comment

Comments

@masterbater
Copy link
Contributor

masterbater commented Dec 22, 2024

  • Laravel-mongodb Version: 5.1
  • PHP Version: 8.3
  • Database Driver & Version:

Description:

Steps to reproduce

doesnt work it doesnt return the latest value,

 public function latestTwilioMessage(): HasOne
    {
        return $this->hasOne(TwilioMessageHistory::class)->latestOfMany('date_sent');
    }
checking latestOfMany method it uses 
    public function latestOfMany($column = 'id', $relation = null)
    {
        return $this->ofMany((new Collection(Arr::wrap($column)))->mapWithKeys(function ($column) {
            return [$column => 'MAX'];
        })->all(), 'MAX', $relation);
    }

For now I use this, seems to work ok.

 public function latestTwilioMessage(): HasOne
    {
        return $this->hasOne(TwilioMessageHistory::class)->latest('date_sent');
    }
@GromNaN
Copy link
Member

GromNaN commented Jan 23, 2025

I'm looking at this issue. Tracked in Jira: PHPORM-281

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants