getColumnValue() public method

Get column value of row item
public getColumnValue ( Row $row ) : mixed
$row Ublaboo\DataGrid\Row
return mixed
Beispiel #1
0
 /**
  * Format row item value
  * @param  Row   $row
  * @return mixed
  */
 public function getColumnValue(Row $row)
 {
     $value = parent::getColumnValue($row);
     if (!is_numeric($value)) {
         return $value;
     }
     return number_format($value, $this->number_format[0], $this->number_format[1], $this->number_format[2]);
 }
Beispiel #2
0
 /**
  * Format row item value as DateTime
  * @param  Row $row
  * @return string
  */
 public function getColumnValue(Row $row)
 {
     $value = parent::getColumnValue($row);
     if (!$value instanceof DateTime) {
         /**
          * Try to convert string to DateTime object
          */
         try {
             $date = DateTimeHelper::tryConvertToDateTime($value);
             return $date->format($this->format);
         } catch (DataGridDateTimeHelperException $e) {
             /**
              * Otherwise just return raw string
              */
             return $value;
         }
     }
     return $value->format($this->format);
 }
 /**
  * Format item value as DateTime
  * @param  mixed $item
  * @return mixed
  */
 public function getColumnValue($item)
 {
     $value = parent::getColumnValue($item);
     if (!$value instanceof DateTime) {
         /**
          * Try to convert string Y-m-d to DateTime object
          */
         $date = \DateTime::createFromFormat('Y-m-d', $value);
         if ($date) {
             return $date->format($this->format);
         }
         /**
          * Try to convert string Y-m-d H:i:s to DateTime object
          */
         $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
         if ($date) {
             return $date->format($this->format);
         }
         /**
          * Try to convert string Y-m-d H:i:s.u to DateTime object
          */
         $date = \DateTime::createFromFormat('Y-m-d H:i:s.u', $value);
         if ($date) {
             return $date->format($this->format);
         }
         /**
          * Try strtotime
          */
         $timestamp = strtotime($value);
         if (FALSE !== $timestamp) {
             $date = new \DateTime();
             $date->setTimestamp($timestamp);
             return $date->format($this->format);
         }
         /**
          * Otherwise just return raw string
          */
         return $value;
     }
     return $value->format($this->format);
 }