Uploaded image for project: 'PHP ORMs'
  1. PHP ORMs
  2. PHPORM-281

laravel-mongodb - Issue #3231: latestOfMany() doesnt work

    • Type: Icon: New Feature New Feature
    • Resolution: Declined
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      masterbater has created Issue #3231: latestOfMany() doesnt work in laravel-mongodb. This Jira ticket was filed by GromNaN

      Issue Text:

      • 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');
          }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            dbeng-pm-bot TPM Jira Automations Bot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None