protected function getAttachmentsToProcess(AttachableInterface $model)
    {
        $attachments     = $model->getAttachedFiles();
        $attachmentNames = $this->option('attachments');

        $availableAttachmentNames = array_map(
            function (AttachmentInterface $attachment) {
                return $attachment->name();
            },
            $attachments
        );

        if (empty($attachmentNames)) {
            return $availableAttachmentNames;
        }

        $attachmentNames = explode(',', str_replace(', ', ',', $attachmentNames));

        $unavailableNames = array_diff($attachmentNames, $availableAttachmentNames);
        if (count($unavailableNames)) {
            throw new UnexpectedValueException(
                get_class($model) . ' does not have attachment(s): ' . implode(', ', $unavailableNames)
            );
        }

        return array_intersect($availableAttachmentNames, $attachmentNames);
    }
protected function getAttachmentsToProcess(AttachableInterface $model)
    {
        $attachments     = $model->getAttachedFiles();
        $attachmentNames = $this->option('attachments');

        $availableAttachmentNames = array_map(
            function (AttachmentInterface $attachment) {
                return $attachment->name();
            },
            $attachments
        );

        if (empty($attachmentNames)) {
            return $availableAttachmentNames;
        }

        $attachmentNames = explode(',', str_replace(', ', ',', $attachmentNames));

        $unavailableNames = array_diff($attachmentNames, $availableAttachmentNames);
        if (count($unavailableNames)) {
            throw new UnexpectedValueException(
                get_class($model) . ' does not have attachment(s): ' . implode(', ', $unavailableNames)
            );
        }

        return array_intersect($availableAttachmentNames, $attachmentNames);
    }
protected function getAttachmentsToProcess ( AttachableInterface $ model ) { $ attachments = $ model -> getAttachedFiles ( ) ; $ attachmentNames = $ this -> option ( 'attachments' ) ; $ availableAttachmentNames = array_map ( function ( AttachmentInterface $ attachment ) { return $ attachment -> name ( ) ; } , $ attachments ) ; if ( empty ( $ attachmentNames ) ) { return $ availableAttachmentNames ; } $ attachmentNames = explode ( ',' , str_replace ( ', ' , ',' , $ attachmentNames ) ) ; $ unavailableNames = array_diff ( $ attachmentNames , $ availableAttachmentNames ) ; if ( count ( $ unavailableNames ) ) { throw new UnexpectedValueException ( get_class ( $ model ) . ' does not have attachment(s): ' . implode ( ', ' , $ unavailableNames ) ) ; } return array_intersect ( $ availableAttachmentNames , $ attachmentNames ) ; }
Returns the attachment names that should be procesed for a given model.

This takes into account the given attachments listed as a command option,
and filters out any attachments that don't exist.

@param AttachableInterface $model
@return string[]
Returns the attachment names that should be procesed for a given model .