Example #1
0
 /**
  * @param Laralist $list
  * @param string $field
  * @param string $keyField
  * @param string $label
  */
 function __construct(Laralist $list, $field, $keyField = null, $label = null)
 {
     $relation = $list->getCallable($list->model, $field, false);
     if (!isset($keyField)) {
         $keyField = $relation->getKeyName();
     }
     parent::__construct($list, $field, $relation->newQuery()->lists($list->getRelationField($field), $keyField), $label);
 }
Example #2
0
 /**
  * Get label translation from list fields if available
  *
  * @param string $field
  * @return null|string
  */
 private function parseLabel($field)
 {
     $listFields = $this->list->fields();
     if (!isset($listFields[$field])) {
         return;
     }
     $params = $this->list->paramsOf($field);
     return $params['translation'];
 }