/** * Get the value of $property from $item * * Used by the WireArray::sort method to retrieve a value from a Wire object. * If output formatting is on, we turn it off to ensure that the sorting * is performed without output formatting. * * @param Wire $item * @param string $property * @return mixed * */ protected function getItemPropertyValue(Wire $item, $property) { if ($item instanceof Page) { $value = $item->getUnformatted($property); } else { if (strpos($property, '.') !== false) { $value = WireData::_getDot($property, $item); } else { if ($item instanceof WireArray) { $value = $item->getProperty($property); if (is_null($value)) { $value = $item->first(); $value = $this->getItemPropertyValue($value, $property); } } else { $value = $item->{$property}; } } } if (is_array($value)) { $value = implode('|', $value); } return $value; }
/** * Get the value of $property from $item * * Used by the WireArray::sort method to retrieve a value from a Wire object. * Primarily here as a template method so that it can be overridden. * Lets it prepare the Wire for any states needed for sorting. * * @param Wire $item * @param string $property * @return mixed * */ protected function getItemPropertyValue(Wire $item, $property) { if (strpos($property, '.') !== false) { return WireData::_getDot($property, $item); } return $item->{$property}; }