rayzenai / file-manager
This is FileHandling package to be used with FilamentPHP/Laravel.
Fund package maintenance!
kirantimsina
Requires
- php: ^8.2
- filament/filament: ^3.2
- illuminate/contracts: ^10.0||^11.0
- illuminate/support: ^10.0||^11.0
- intervention/image: ^3.9
- league/flysystem-aws-s3-v3: ^3.29
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
This package is not auto-updated.
Last update: 2024-12-20 04:41:47 UTC
README
RayzenAI File Manager for Filament with S3
The RayzenAI File Manager is a Laravel package built specifically for Filament, providing a user-friendly, SEO-optimized way to manage images and files in your application. It integrates seamlessly with Filament, making it easy to handle file uploads, retrieval, and organization, all while ensuring SEO best practices.
This package is developed and maintained by RayzenTech.
About RayzenTech
RayzenTech is a tech startup based in Nepal focused on creating smart business solutions. We specialize in automating complex processes and making them simple, from business automation to robotic process automation. Our goal is to make life easier with innovative technology.
Learn more about us at RayzenTech.
Installation
Follow these steps to install the package in your Filament-powered Laravel application:
-
Install the package via Composer:
composer require rayzenai/file-manager
-
Publish the configuration file with:
php artisan vendor:publish --tag="file-manager-config"
This will generate a configuration file
file-manager.php
in config folder where you can customize the file manager settings. -
Define the models and their corresponding path names in the configuration file. Example:
<?php return [ 'User' => 'users', // Define other models and their path names here according to your project ];
Usage in Model
To use the RayzenAI File Manager in your Filament project, you need to use the trait HasImages
.
-
Use the
HasImages
Trait:In the model where you want to manage files, use the
HasImages
trait. This allows your model to manage file uploads and retrievals easily.Example:
use Kirantimsina\FileManager\Traits\HasImages; class YourModel extends Model implements InterfacesHasImages { use HasFactory, HasImages; protected $guarded = ['id']; // This protects the 'id' field // We define the 'images' field as an array protected $casts = [ 'images' => 'array', ]; // Specify which fields in this model will handle images. This is used for resizing protected function hasImagesTraitFields(): array { return ['images']; } }
Explanation:
HasImages Trait
: This trait provides the actual methods for uploading, retrieving, and storing images.$casts
: We cast theimages
field to an array so you can easily store multiple image paths in one field.hasImagesTraitFields
: This method defines which fields (in this case,images
) will be used to handle images resizing.
After setting this up, your Filament-powered model will be ready to handle file uploads, organize them efficiently, and ensure everything is SEO-friendly.
Usage in Resource
ImageUpload
The ImageUpload
component works similarly to Filament's FileUpload
, but with additional customizations that enhance file management. It systematically saves your files and generates SEO-friendly URLs. Essentially, it extends Filament's FileUpload
functionality to improve its usability and performance.
ImageUpload::make('images') ->label('Images'),
S3Image
The S3Image
is an enhanced version of the ImageColumn
. It displays images in a table, and when an image is clicked, a larger view opens in a side modal. Like ImageColumn, it is built on top of Filament but includes additional customization features to improve the user experience.
S3Image::make('images') ->label('Images'),
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.