示例#1
0
 public static function store($dailyAmount, $from, $to, Property $property, $media = [], $id = null)
 {
     $media_ids = [];
     if (!is_array($media)) {
         $media = [$media];
     }
     foreach ($media as $single_media) {
         if ($single_media instanceof Media) {
             $media_ids[] = $single_media->id;
         }
     }
     $dailyAmount = numfmt_parse(numfmt_create('en_AU', NumberFormatter::DECIMAL), $dailyAmount) ?: numfmt_parse(numfmt_create('en_AU', NumberFormatter::CURRENCY), $dailyAmount);
     return self::updateOrCreate(['id' => $id], ['dailyAmount' => $dailyAmount, 'from' => empty($from) ? null : new Carbon($from), 'to' => empty($to) ? null : new Carbon($to), 'property_id' => $property->id, 'media_ids' => json_encode($media_ids)]);
 }
示例#2
0
 /**
  * Defined by Zend\Filter\FilterInterface
  *
  * @see    Zend\Filter\FilterInterface::filter()
  * @param  mixed $value
  * @return mixed
  */
 public function filter($value)
 {
     $formatter = $this->getFormatter();
     $type = $this->getType();
     if (is_int($value) || is_float($value)) {
         $result = @numfmt_format($formatter, $value, $type);
     } else {
         $value = str_replace(array(" ", ' '), '', $value);
         $result = @numfmt_parse($formatter, $value, $type);
     }
     if ($result === false) {
         return $value;
     }
     return str_replace(" ", ' ', $result);
 }