DEV Community

Cover image for Laravel Secret Image
Mohsen Bostan
Mohsen Bostan

Posted on

Laravel Secret Image

Hi, everyone!
I've created a useful package for Laravel developers. This package will help you to save your images secretly and show them to ones who you choose.

You can access this package by this link:

GitHub logo mohsenbostan / laravel-secret-image

A package to save images secretly.

Laravel Secret Image

Latest Version on Packagist Total Downloads Build Status

This package helps you to save your images secretly and show them just to authenticated users.

Installation

You can install the package via composer:

composer require mohsenbostan/laravel-secret-image
Enter fullscreen mode Exit fullscreen mode

after installing package using composer, you should publish configs:

php artisan vendor:publish --provider=Mohsenbostan\LaravelSecretImage\LaravelSecretImageServiceProvider
Enter fullscreen mode Exit fullscreen mode

Usage

Custom Storage Driver

you can set a custom storage driver in config/laravel-secret-image.php

<?php

return [
    /*
     * Default Storage Driver To Save Images
     * -------------------------------------
     * Note: Don't use `public` for driver or path.
     */
    'storage_driver' => env('FILESYSTEM_DRIVER', 'local'),
];
Enter fullscreen mode Exit fullscreen mode

Custom Middlewares

you can set custom middlewares to protect images in config/laravel-secret-image.php

<?php

return [
    /*
     * Default Middlewares To Protect Images
     */
    'middlewares' => [
        'auth'
    ]
];
Enter fullscreen mode Exit fullscreen mode

Save Single Secret Image

saveSingleImage method will save image and return the image path.

use  \Mohsenbostan\LaravelSecretImage\LaravelSecretImage
$image = LaravelSecretImage::saveSingleImage(request()->file
Enter fullscreen mode Exit fullscreen mode

I'd be so happy if you contribute to the package to make it better.

Top comments (0)