示例#1
0
 /**
  * Constructor function
  *
  * @param string|int	$field
  * @param array|string	$info
  * @param ModelConfig 	$config
  */
 public function __construct($field, $info, $config)
 {
     parent::__construct($field, $info, $config);
     $this->sizes = array_get($info, 'sizes', $this->sizes);
     $this->naming = array_get($info, 'naming', $this->naming);
     $this->location = array_get($info, 'location');
     $this->sizeLimit = (int) array_get($info, 'size_limit', $this->sizeLimit);
     $this->uploadUrl = \URL::to_route('admin_image_upload', array($config->name, $this->field));
     $replace = path('public');
     if (strpos($this->location, $replace) === 0) {
         $this->displayUrl = \URL::to('/' . substr_replace($this->location, '', 0, strlen($replace)));
     }
     //make sure the naming is one of the two accepted values
     $this->naming = in_array($this->naming, array('keep', 'random')) ? $this->naming : 'random';
 }
示例#2
0
 /**
  * Constructor function
  *
  * @param string|int	$field
  * @param array|string	$info
  * @param ModelConfig 	$config
  */
 public function __construct($field, $info, $config)
 {
     parent::__construct($field, $info, $config);
     $isSettings = is_a($config, 'Admin\\Libraries\\SettingsConfig');
     $this->mimes = array_get($info, 'mimes', $this->mimes);
     $this->naming = array_get($info, 'naming', $this->naming);
     $this->length = array_get($info, 'length', $this->length);
     $this->location = array_get($info, 'location');
     $this->sizeLimit = (int) array_get($info, 'size_limit', $this->sizeLimit);
     if ($isSettings) {
         $this->uploadUrl = URL::to_route('admin_settings_file_upload', array($config->name, $this->field));
     } else {
         $this->uploadUrl = URL::to_route('admin_file_upload', array($config->name, $this->field));
     }
     //make sure the naming is one of the two accepted values
     $this->naming = in_array($this->naming, array('keep', 'random')) ? $this->naming : 'random';
     // Satisfy params for Multup, for keep we return false so we don't random filename
     $this->naming = $this->naming == 'keep' ? false : true;
 }
示例#3
0
 /**
  * Constructor function
  *
  * @param string|int	$field
  * @param array|string	$info
  * @param Eloquent 		$model
  */
 public function __construct($field, $info, $model)
 {
     parent::__construct($field, $info, $model);
     //get an instance of the relationship object
     $relationship = $model->{$field}();
     //get the name field option
     $this->nameField = array_get($info, 'name_field', $this->nameField);
     $this->autocomplete = array_get($info, 'autocomplete', $this->autocomplete);
     $this->numOptions = array_get($info, 'num_options', $this->numOptions);
     $this->searchFields = array_get($info, 'search_fields', array($this->nameField));
     //if we want all of the possible items on the other model, load them up, otherwise leave the options empty
     $options = array();
     if (array_get($info, 'load_relationships', false)) {
         $options = $relationship->model->all();
     } else {
         if ($relationshipItems = $relationship->get()) {
             $options = $relationshipItems;
         }
     }
     //map the options to the options property where array([key]: int, [name_field]: string)
     $this->options = array_map(function ($m) use($info, $model) {
         return array($m::$key => $m->{$m::$key}, $info['name_field'] => $m->{$info['name_field']});
     }, $options);
 }
示例#4
0
 /**
  * Constructor function
  *
  * @param string|int	$field
  * @param array|string	$info
  * @param ModelConfig 	$config
  */
 public function __construct($field, $info, $config)
 {
     parent::__construct($field, $info, $config);
     //put the model into a variable so we can call it statically
     $model = $config->model;
     //get an instance of the relationship object
     $relationship = $model->{$field}();
     //get the name field option
     $this->nameField = array_get($info, 'name_field', $this->nameField);
     $this->autocomplete = array_get($info, 'autocomplete', $this->autocomplete);
     $this->numOptions = array_get($info, 'num_options', $this->numOptions);
     $this->searchFields = array_get($info, 'search_fields', array($this->nameField));
     $this->selfRelationship = $relationship->model->table() === $model->table();
     //set up and check the constraints
     $this->setUpConstraints($info, $model);
     //if we want all of the possible items on the other model, load them up, otherwise leave the options empty
     $options = array();
     if (array_get($info, 'load_relationships', false)) {
         $options = $relationship->model->all();
     } else {
         if ($relationshipItems = $relationship->get()) {
             $options = $relationshipItems;
         }
     }
     $nameField = $this->nameField;
     //map the options to the options property where array([key]: int, [name_field]: string)
     $this->options = array_map(function ($m) use($nameField, $model) {
         return array($m::$key => $m->{$m::$key}, $nameField => $m->{$nameField});
     }, $options);
 }
示例#5
0
 /**
  * Constructor function
  *
  * @param string|int	$field
  * @param array|string	$info
  * @param ModelConfig 	$config
  */
 public function __construct($field, $info, $config)
 {
     parent::__construct($field, $info, $config);
     $this->date_format = array_get($info, 'date_format', $this->date_format);
     $this->time_format = array_get($info, 'time_format', $this->time_format);
 }