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

isFillable() public method

Determine if the given attribute may be mass assigned.
public isFillable ( string $key ) : boolean
$key string
return boolean
    public function isFillable($key)
    {
        if (static::$unguarded) {
            return true;
        }
        // If the key is in the "fillable" array, we can of course assume that it's
        // a fillable attribute. Otherwise, we will check the guarded array when
        // we need to determine if the attribute is black-listed on the model.
        if (in_array($key, $this->getFillable())) {
            return true;
        }
        if ($this->isGuarded($key)) {
            return false;
        }
        return empty($this->getFillable()) && !Str::startsWith($key, '_');
    }

Usage Example

 /**
  * Flush the cache for this Model Object instance
  *
  * @param Model $model
  * @return void
  */
 public function flush(Model $model)
 {
     // Assemble Cache Keys
     $keys[] = $this->resourceName . '.hash.' . $model->hash;
     $keys[] = $this->resourceName . '.id.' . $model->id;
     // Some keys will not be available on all models
     if ($this->model->isFillable('ref')) {
         $keys[] = $this->resourceName . '.ref.' . $model->ref;
     }
     // Clear the cache for the given keys
     foreach ($keys as $key) {
         $this->cache->forget($key);
     }
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::isFillable
Model