classes/Models/Traits/HasImages.php
public function appendToImgs(Image $image, $property)
    {
        // Create or fetch the container for all images on the model. The
        // container could not be "images" because that is used by the
        // relationship function and leads to trouble.
        if (!$this->getAttribute('imgs')) {
            $imgs = [];
            $this->addVisible('imgs');
        } else {
            $imgs = $this->getAttribute('imgs');
        }

        // Add the image to the container and set it.  Then return the model. It
        // must be explicitly converted to an array because Laravel won't
        // automatically do it during collection serialization. Another, more
        // complicated approach could have been to use the Decoy Base model to add
        // a cast type of "model" and then call toArray() on it when casting the
        // attribute.
        $imgs[$property] = $image->toArray();
        $this->setAttribute('imgs', $imgs);

        return $this;
    }
public function appendToImgs(Image $image, $property)
    {
        // Create or fetch the container for all images on the model. The
        // container could not be "images" because that is used by the
        // relationship function and leads to trouble.
        if (!$this->getAttribute('imgs')) {
            $imgs = [];
            $this->addVisible('imgs');
        } else {
            $imgs = $this->getAttribute('imgs');
        }

        // Add the image to the container and set it.  Then return the model. It
        // must be explicitly converted to an array because Laravel won't
        // automatically do it during collection serialization. Another, more
        // complicated approach could have been to use the Decoy Base model to add
        // a cast type of "model" and then call toArray() on it when casting the
        // attribute.
        $imgs[$property] = $image->toArray();
        $this->setAttribute('imgs', $imgs);

        return $this;
    }
public function appendToImgs ( Image $ image , $ property ) { // Create or fetch the container for all images on the model. The // container could not be "images" because that is used by the // relationship function and leads to trouble. if ( ! $ this -> getAttribute ( 'imgs' ) ) { $ imgs = [ ] ; $ this -> addVisible ( 'imgs' ) ; } else { $ imgs = $ this -> getAttribute ( 'imgs' ) ; } // Add the image to the container and set it.  Then return the model. It // must be explicitly converted to an array because Laravel won't // automatically do it during collection serialization. Another, more // complicated approach could have been to use the Decoy Base model to add // a cast type of "model" and then call toArray() on it when casting the // attribute. $ imgs [ $ property ] = $ image -> toArray ( ) ; $ this -> setAttribute ( 'imgs' , $ imgs ) ; return $ this ; }
Add an Image to the `imgs` attribute of the model for the purpose of
exposing it when serialized.

@param  Image  $image
@param  string $property
@return $this
Add an Image to the imgs attribute of the model for the purpose of exposing it when serialized .