Download the PHP package elseoclub/modelfiler without Composer
On this page you can find all versions of the php package elseoclub/modelfiler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package modelfiler
# Modelfiler Package
The Modelfiler package allows you to easily manage file uploads associated with any Eloquent model in Laravel. This package supports polymorphic relationships and provides flexible configuration options for file types.
Installation
To install the Modelfiler package, you can include it in your composer.json or run:
Usage
1. Set Up Your Model
To use the Modelfiler package, you need to add the WithModelFiler trait to your model. For example, if you want to use
it in the User model:
2. File Type Configuration
In your model, define the $fileTypes array to specify the file types you want to store. Each file type should have the
following attributes:
- accept: The MIME types you want to allow (e.g.,
.jpg,.png,.jpeg,.gif,.svg). - storage: Where the file will be stored (default is
local). - max_size: Maximum file size in kilobytes (default is
102400). - unique: Whether to overwrite the current file if it exists (default is
false). - path: The folder path where it will be stored. If not defined, the file will be stored in the folder
[ModelName]/[FileTypeName].
3. File Uploads
Once you have added the necessary setup to your model, you can easily add files. For example:
4. File Management
-
To get all user files:
-
To get all user picture files:
-
To paginate user picture files:
- To delete a user file:
5. Accepted MIME Types
To get the accepted MIME types for use in a file input:
You can then use it in your Blade template like this:
6. Validation Rules
To add validation rules for file uploads:
Conclusion
The Modelfiler package simplifies the process of managing file uploads for your models, providing a robust and flexible way to handle file types and storage options. For more details, refer to the package documentation or the source code.
If you have any questions or need further assistance, feel free to reach out!
All versions of modelfiler with dependencies
illuminate/support Version ^10.0 || ^11.0
illuminate/filesystem Version ^10.0 || ^11.0