本文整理匯總了PHP中Illuminate\Database\Eloquent\Model::getHidden方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::getHidden方法的具體用法?PHP Model::getHidden怎麽用?PHP Model::getHidden使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::getHidden方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Create new instance of eloquent type.
*
* @param Model $model
*/
public function __construct(Model $model, $name = '')
{
$this->name = $name;
$this->fields = collect();
$this->hiddenFields = collect($model->getHidden())->flip();
$this->model = $model;
$this->camelCase = config('relay.camel_case', false);
}
示例2: castModel
/**
* 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;
}
示例3: process
/**
* Applies processing to a single model
*
* @param Model $model
* @return Model
*/
public function process(Model $model)
{
$hiddenOnModel = $model->getHidden();
foreach ($this->unhidden as $unhidden) {
if (($key = array_search($unhidden, $hiddenOnModel)) !== false) {
unset($hiddenOnModel[$key]);
}
}
$hiddenOnModel = array_merge($hiddenOnModel, $this->hidden);
$model->setHidden($hiddenOnModel);
return $model;
}
示例4: getVisibleIndexCasts
/**
* 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()));
}
示例5: __construct
/**
* ModelSnapshot constructor.
*
* @param Model $model
* @param string $event
*/
protected function __construct(Model $model, $event)
{
$this->model = $model->makeVisible($model->getHidden());
$this->event = $event;
}