private function commonCustomRecord($parameters)
 {
     $parameters['statuses'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('booking.status'));
     $parameters['places'] = Place::builder()->get();
     $parameters['nAdults'] = range(0, 29);
     array_walk($parameters['nAdults'], function (&$object, $key) {
         $object = new \stdClass();
         $object->id = $key + 1;
         $object->name = $key + 1 . ' ' . trans_choice('pulsar::pulsar.adult', $key + 1);
     });
     $parameters['nChildren'] = range(0, 9);
     array_walk($parameters['nChildren'], function (&$object, $key) {
         $object = new \stdClass();
         $object->id = $key + 1;
         $object->name = $key + 1 . ' ' . trans_choice('pulsar::pulsar.child', $key + 1);
     });
     $parameters['nRooms'] = range(0, 29);
     array_walk($parameters['nRooms'], function (&$object, $key) {
         $object = new \stdClass();
         $object->id = $key + 1;
         $object->name = $key + 1 . ' ' . trans_choice('hotels::pulsar.room', $key + 1);
     });
     $parameters['temporaryBeds'] = range(0, 4);
     array_walk($parameters['temporaryBeds'], function (&$object, $key) {
         $object = new \stdClass();
         $object->id = $key + 1;
         $object->name = $key + 1 . ' ' . trans_choice('booking::pulsar.temporary_bed', $key + 1);
     });
     $parameters['breakfast'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('booking.breakfast'));
     $parameters['commissions'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('booking.commissions'));
     $parameters['taxes'] = array_map(function ($object) {
         if (trans_has($object->name)) {
             $object->name = trans($object->name);
         }
         return $object;
     }, config('booking.taxes'));
     return $parameters;
 }
Example #2
0
 /**
  * Overwritte construct to set params to model
  *
  * Model constructor.
  * @param array $attributes
  */
 function __construct(array $attributes = [])
 {
     // set translation name of table
     if (!empty($this->package) && empty($this->tableTranslation)) {
         $this->tableTranslation = $this->package . '::tables.' . $this->table;
     }
     // set column translations
     if (empty($this->columnTranslation)) {
         $this->columnTranslation = [];
         foreach ($this->fillable as $column) {
             if (trans_has($this->package . '::tables.' . $column)) {
                 $this->columnTranslation[$column] = $this->package . '::tables.' . $column;
             }
         }
     }
     // set maps to model
     $fields = $this->fillable;
     // set maps if not exist
     if (!isset($this->maps) || !is_array($this->maps)) {
         throw new InvalidArgumentException('The array maps is not instantiated, you must instantiate in model ' . get_class($this));
     }
     foreach ($fields as $field) {
         $this->maps[str_replace('_' . $this->suffix, '', $field)] = $field;
     }
     // set maps from relations
     if (isset($this->relationMaps)) {
         foreach ($this->relationMaps as $key => $relationClass) {
             $object = new $relationClass();
             $maps = $object->getMaps();
             foreach ($maps as $keyMap => $map) {
                 $this->maps[$key . '_' . $keyMap] = $map;
             }
             // set translations columns from related models
             if (is_array($object->columnTranslation) && is_array($this->columnTranslation)) {
                 $this->columnTranslation = array_merge($this->columnTranslation, $object->columnTranslation);
             } else {
                 $this->columnTranslation = $object->columnTranslation;
             }
         }
     }
     // call parent constructor on Illuminate\Database\Eloquent\Model
     parent::__construct($attributes);
 }