Looking to hire Laravel developers? Try LaraJobs

swift-media maintained by laravel-daddy

Description
Easy way to manage multimedia with polymorphic table
Last update
2024/10/09 17:06 (dev-master)
License
Links
Downloads
11

Comments
comments powered by Disqus

Swift Media Package

Crafted with ♥️ by Laravel Daddy

Installation

To install the package, run the following command:

composer require laravel-daddy/swift-media
php artisan vendor:publish --tag=migrations

Upon installation, the package will automatically publish the necessary migrations and register the SwiftMediaServiceProvider.

Usage

All media are automatically cached to enhance the performance of your application. This ensures that accessing settings is efficient and optimized.

You can manage settings using either the facade or the helper method.

Using the Facade

use LaravelDaddy\SwiftSettings\Facade\SwiftSettingsFacade;

// will upload file and delete old file if exist
SwiftMedia::uploadFile($model_type= User::class, $model_id= 2, $attribute= 'profile', $file, $path= '/');
SwiftMedia::deleteFile($model_type= User::class, $model_id= 2, $attribute= 'profile');
SwiftMedia::getAllFiles();
SwiftMedia::getAllFilesPaginated($limit = 20);

Using the Helper Method

// will upload file and delete old file if exist
swift_media()->uploadFile($model_type= User::class, $model_id= 2, $attribute= 'profile', $file, $path= '/');
swift_media()->deleteFile($model_type= User::class, $model_id= 2, $attribute= 'profile');
swift_media()->getAllFiles();
swift_media()->getAllFilesPaginated($limit = 20);

Both approaches allow you to retrieve or update media efficiently, with all keys being cached for improved performance.