src/Traits/Mediables.php
public function resolveMediableValue($value)
    {
        // If is directly from upload request then store it.
        if ($value instanceof UploadedFile) {
            $value = Media::store($value);
        }

        // If it's a media file get id.
        if ($value instanceof Model) {
            $value = $value->id;
        }

        // For single and multi values
        if ($value) {
            $value = is_array($value) ? $value : [$value];
        } else {
            $value = $this->exists ? [] : null;
        }

        // Array should contain only integer values
        // If they're not - that means was given file object as array
        $value = collect($value)->filter(function ($value, $key) {
            return is_integer($key) || $key == 'id';
        })->toArray();

        return $value;
    }
public function resolveMediableValue($value)
    {
        // If is directly from upload request then store it.
        if ($value instanceof UploadedFile) {
            $value = Media::store($value);
        }

        // If it's a media file get id.
        if ($value instanceof Model) {
            $value = $value->id;
        }

        // For single and multi values
        if ($value) {
            $value = is_array($value) ? $value : [$value];
        } else {
            $value = $this->exists ? [] : null;
        }

        // Array should contain only integer values
        // If they're not - that means was given file object as array
        $value = collect($value)->filter(function ($value, $key) {
            return is_integer($key) || $key == 'id';
        })->toArray();

        return $value;
    }
public function resolveMediableValue ( $ value ) { // If is directly from upload request then store it. if ( $ value instanceof UploadedFile ) { $ value = Media :: store ( $ value ) ; } // If it's a media file get id. if ( $ value instanceof Model ) { $ value = $ value -> id ; } // For single and multi values if ( $ value ) { $ value = is_array ( $ value ) ? $ value : [ $ value ] ; } else { $ value = $ this -> exists ? [ ] : null ; } // Array should contain only integer values // If they're not - that means was given file object as array $ value = collect ( $ value ) -> filter ( function ( $ value , $ key ) { return is_integer ( $ key ) || $ key == 'id' ; } ) -> toArray ( ) ; return $ value ; }
Resolve value of given model.

@param  \Routegroup\Media\File|\Illuminate\Http\UploadedFile|integer $value
@return array|null
Resolve value of given model .