src/AttachableTrait.php
public function updateOrNewAttach($filename, $title=null, $alt=null, $desc=null)
    {
        if(Storage::exists($filename)){
            $namespace = $this->getEntityClassName();

            $attach = $this
                ->createAttachesModel()
                ->whereNamespace($namespace)
                ->where(function ($query) use ($filename) {
                    $query
                        ->orWhere('filename', $filename)
                    ;
                })
                ->first()
            ;

            if ($attach) {
                $attach->title=$title;
                $attach->alt=$alt;
                $attach->desc=$desc;
                $attach->save();
            }
        }

        else $this->addAttach($filename, $title, $alt, $desc);
    }
public function updateOrNewAttach($filename, $title=null, $alt=null, $desc=null)
    {
        if(Storage::exists($filename)){
            $namespace = $this->getEntityClassName();

            $attach = $this
                ->createAttachesModel()
                ->whereNamespace($namespace)
                ->where(function ($query) use ($filename) {
                    $query
                        ->orWhere('filename', $filename)
                    ;
                })
                ->first()
            ;

            if ($attach) {
                $attach->title=$title;
                $attach->alt=$alt;
                $attach->desc=$desc;
                $attach->save();
            }
        }

        else $this->addAttach($filename, $title, $alt, $desc);
    }
{@inheritdoc}