classes/Controllers/Elements.php
protected function storeImage(Element $el, $input)
    {
        // Do nothing if no images
        if (!is_array($input['images'])) {
            return;
        }

        // Check for the image in the input.  If isn't found, make no changes.
        $name = $el->inputName();
        if (!$data = array_first($input['images'],
            function ($data, $id) use ($name) {
                return $data['name'] == $name;
            })) {
            return;
        }

        // Update an existing image
        if ($image = $el->images->first()) {
            $image->fill($data)->save();

        // Or create a new image, if file data was supplied
        } elseif (!empty($data['file'])) {
            $el->value = null;
            $el->save();
            $image = new Image($data);
            $el->images()->save($image);

        // Othweise, nothing to do
        } else {
            return;
        }

        // Update the element with the path to the image
        $el->value = $image->file;
        $el->save();
    }
protected function storeImage(Element $el, $input)
    {
        // Do nothing if no images
        if (!is_array($input['images'])) {
            return;
        }

        // Check for the image in the input.  If isn't found, make no changes.
        $name = $el->inputName();
        if (!$data = array_first($input['images'],
            function ($data, $id) use ($name) {
                return $data['name'] == $name;
            })) {
            return;
        }

        // Update an existing image
        if ($image = $el->images->first()) {
            $image->fill($data)->save();

        // Or create a new image, if file data was supplied
        } elseif (!empty($data['file'])) {
            $el->value = null;
            $el->save();
            $image = new Image($data);
            $el->images()->save($image);

        // Othweise, nothing to do
        } else {
            return;
        }

        // Update the element with the path to the image
        $el->value = $image->file;
        $el->save();
    }
protected function storeImage ( Element $ el , $ input ) { // Do nothing if no images if ( ! is_array ( $ input [ 'images' ] ) ) { return ; } // Check for the image in the input.  If isn't found, make no changes. $ name = $ el -> inputName ( ) ; if ( ! $ data = array_first ( $ input [ 'images' ] , function ( $ data , $ id ) use ( $ name ) { return $ data [ 'name' ] == $ name ; } ) ) { return ; } // Update an existing image if ( $ image = $ el -> images -> first ( ) ) { $ image -> fill ( $ data ) -> save ( ) ; // Or create a new image, if file data was supplied } elseif ( ! empty ( $ data [ 'file' ] ) ) { $ el -> value = null ; $ el -> save ( ) ; $ image = new Image ( $ data ) ; $ el -> images ( ) -> save ( $ image ) ; // Othweise, nothing to do } else { return ; } // Update the element with the path to the image $ el -> value = $ image -> file ; $ el -> save ( ) ; }
Handle storage of image Element types

@param  Element $el
@param  array   $input
@return void
Handle storage of image Element types