Illuminate\Database\Eloquent\Model::getCasts PHP Method

getCasts() public method

Get the casts array.
public getCasts ( ) : array
return array
    public function getCasts()
    {
        if ($this->getIncrementing()) {
            return array_merge([$this->getKeyName() => $this->getKeyType()], $this->casts);
        }
        return $this->casts;
    }

Usage Example

Example #1
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()));
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::getCasts
Model