getVisible() публичный Метод

Get the visible attributes for the model.
public getVisible ( ) : array
Результат array
 /**
  * Get an array representing the properties of a model.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return array
  */
 public static function castModel(Model $model)
 {
     $attributes = array_merge($model->getAttributes(), $model->getRelations());
     $visible = array_flip($model->getVisible() ?: array_diff(array_keys($attributes), $model->getHidden()));
     $results = [];
     foreach (array_intersect_key($attributes, $visible) as $key => $value) {
         $results[(isset($visible[$key]) ? Caster::PREFIX_VIRTUAL : Caster::PREFIX_PROTECTED) . $key] = $value;
     }
     return $results;
 }
Пример #2
0
 /**
  * Get the visible model casts for the index.
  *
  * @param  \Illuminate\Database\Eloquent\Model $model
  * @return array
  */
 protected function getVisibleIndexCasts(BaseModel $model)
 {
     if (count($model->getVisible()) > 0) {
         return array_intersect_key($model->getCasts(), array_flip($model->getVisible()));
     }
     return array_diff_key($model->getCasts(), array_flip($model->getHidden()));
 }