src/Observers/FileObserver.php
public function creating(Model $model)
    {
        if (request()->hasFile('name')) {
            // delete prev image
            $file = $this->fileUploader->handle(request()->file('name'));
            $model->name = $file['filename'];
            $model->fill(Arr::except($file, 'filename'));
        } else {
            if ($model->type !== 'f') {
                return false;
            }
        }
    }
public function creating(Model $model)
    {
        if (request()->hasFile('name')) {
            // delete prev image
            $file = $this->fileUploader->handle(request()->file('name'));
            $model->name = $file['filename'];
            $model->fill(Arr::except($file, 'filename'));
        } else {
            if ($model->type !== 'f') {
                return false;
            }
        }
    }
public function creating ( Model $ model ) { if ( request ( ) -> hasFile ( 'name' ) ) { // delete prev image $ file = $ this -> fileUploader -> handle ( request ( ) -> file ( 'name' ) ) ; $ model -> name = $ file [ 'filename' ] ; $ model -> fill ( Arr :: except ( $ file , 'filename' ) ) ; } else { if ( $ model -> type !== 'f' ) { return false ; } } }
On save, upload files.

@param Model $model eloquent

@return mixed false or void
On save upload files .