src/Services/PostsService.php
/**
     * Delete a blog etc post, return the deleted post and an array of featured images which were associated
     * to the blog post (but which were not deleted form the filesystem).
     *
     * @param int $postID
     *
     * @return array - [Post (deleted post), array (remaining featured photos)
     * @throws Exception
     */
Delete a blog etc post, return the deleted post and an array of featured images which were associated
to the blog post (but which were not deleted form the filesystem).

@param int $postID

@return array - [Post (deleted post), array (remaining featured photos)
@throws Exception
Delete a blog etc post return the deleted post and an array of featured images which were associated to the blog post ( but which were not deleted form the filesystem ) . @param int $postID @return array - [ Post ( deleted post ) array ( remaining featured photos ) @throws Exception
public function delete(int $postID): array
    {
        $post = $this->repository->find($postID);
        event(new BlogPostWillBeDeleted($post));
        $this->repository->delete($postID);
        $remainingPhotos = [];
        foreach ((array) config('blogetc.image_sizes') as $imageSize => $imageSizeInfo) {
            if ($post->$imageSize) {
                $fullPath = config('blogetc.blog_upload_dir', 'blog_images').'/'.$post->$imageSize;
                $fileSize = UploadsService::disk()->getSize($fullPath);
                if ($fileSize !== false) {
                    $fileSize = $this->humanReadableFileSize($fileSize);
                }
                $remainingPhotos[] = [
                    'filename' => $post->$imageSize,
                    'full_path' => $fullPath,
                    'file_size' => $fileSize,
                    'url' => UploadsService::disk()->url($fullPath),
                ];
            }
        }
        return [$post, $remainingPhotos];
    }
public function delete ( int $ postID ) : array { $ post = $ this -> repository -> find ( $ postID ) ; event ( new BlogPostWillBeDeleted ( $ post ) ) ; $ this -> repository -> delete ( $ postID ) ; $ remainingPhotos = [ ] ; foreach ( ( array ) config ( 'blogetc.image_sizes' ) as $ imageSize => $ imageSizeInfo ) { if ( $ post -> $ imageSize ) { $ fullPath = config ( 'blogetc.blog_upload_dir' , 'blog_images' ) . '/' . $ post -> $ imageSize ; $ fileSize = UploadsService :: disk ( ) -> getSize ( $ fullPath ) ; if ( $ fileSize !== false ) { $ fileSize = $ this -> humanReadableFileSize ( $ fileSize ) ; } $ remainingPhotos [ ] = [ 'filename' => $ post -> $ imageSize , 'full_path' => $ fullPath , 'file_size' => $ fileSize , 'url' => UploadsService :: disk ( ) -> url ( $ fullPath ) , ] ; } } return [ $ post , $ remainingPhotos ] ; }
Delete a blog etc post, return the deleted post and an array of featured images which were associated
 to the blog post (but which were not deleted form the filesystem).
Delete a blog etc post return the deleted post and an array of featured images which were associated to the blog post ( but which were not deleted form the filesystem ) .
// Get the post to delete. // Fire 'will be deleted' event: // Delete: // now return an array of image files that are not deleted (so we can tell the user that these featured photos // still exist on the filesystem // there was record of this size in the db, so push it to array of featured photos which remain // (Note: there is no check here to see if they actually exist on the filesystem). // Get the file size, in human readable (kb) format.