MatisseComponents/Handlers/FileFieldHandler.php
private function noUpload (BaseModel $model, $fieldName)
  {
    if (!isset ($model[$fieldName])) {
      // Check is there are already files on this field.
      $filesRelation = $model->files ();
      /** @var Builder $filesQuery */
      $filesQuery = $filesRelation->ofField ($fieldName);
      /** @var File[] $files */
      $files = $filesQuery->get ();

      // Delete the previous files of this field, if any exists.
      foreach ($files as $file)
        $file->delete ();
    }
  }
private function noUpload (BaseModel $model, $fieldName)
  {
    if (!isset ($model[$fieldName])) {
      // Check is there are already files on this field.
      $filesRelation = $model->files ();
      /** @var Builder $filesQuery */
      $filesQuery = $filesRelation->ofField ($fieldName);
      /** @var File[] $files */
      $files = $filesQuery->get ();

      // Delete the previous files of this field, if any exists.
      foreach ($files as $file)
        $file->delete ();
    }
  }
private function noUpload ( BaseModel $ model , $ fieldName ) { if ( ! isset ( $ model [ $ fieldName ] ) ) { // Check is there are already files on this field. $ filesRelation = $ model -> files ( ) ; /** @var Builder $filesQuery */ $ filesQuery = $ filesRelation -> ofField ( $ fieldName ) ; /** @var File[] $files */ $ files = $ filesQuery -> get ( ) ; // Delete the previous files of this field, if any exists. foreach ( $ files as $ file ) $ file -> delete ( ) ; } }
Handle the case where no file has been uploaded for a field, but the field may have been cleared.

@param BaseModel|FilesModelTrait $model
@param string                $fieldName
@throws \Exception
Handle the case where no file has been uploaded for a field but the field may have been cleared .