Nova Larupload
Nova Larupload is a package that integrates Larupload with Laravel Nova. Larupload is a file uploader for Laravel, which is based on ORM and allows users to upload images
, videos
, audios
, and other known file formats.
With Nova Larupload
, you can use the features of both packages to create a admin panel for your Laravel project. You can upload and display various types of files (such as images, videos, audio, etc.) in your Nova resources. You can also transform your files (such as resizing
, cropping
, compressing
, etc.) using Larupload's methods. You can also set your upload settings (such as disk, path, visibility, etc.) using Larupload's options.
Nova Larupload is simple to install and use, and it supports multiple file systems (such as local, s3, sftp, etc.).
I am on an open-source journey 🚀, and I wish I could solely focus on my development path without worrying about my financial situation. However, as life is not perfect, I have to consider other factors.
Therefore, if you decide to use my packages, please kindly consider making a donation. Any amount, no matter how small, goes a long way and is greatly appreciated. 🍺
Requirements:
- PHP 8.2 or higher
- Larupload 1.0.2 or higher
- Laravel 10.4.1 or higher
- Nova 4.27 or higher
Installation and Usage
[!NOTE]
Ensure that you have already installed and configured the Larupload package in your Laravel application. If you haven't done so, please refer to the Larupload documentation for instructions on installation and usage. It's important to create attachments for each model before proceeding with Nova Larupload.
To get started, you will need to install the following dependency:
composer require mostafaznv/nova-larupload
Next, you should publish the package's configuration file using the vendor:publish
Artisan command. This configuration file will be placed in your application's config
directory:
php artisan vendor:publish --provider="Mostafaznv\NovaLarupload\NovaLaruploadServiceProvider"
Then, you should add NovaLarupload field to your resources:
<?php
namespace App\Nova;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use App\Models\Attachment as Model;
use Mostafaznv\NovaLarupload\Fields\NovaLarupload;
class Attachment extends Resource
{
public static string $model = Model::class;
public static $title = 'title';
public function fields(NovaRequest $request): array
{
return [
ID::make()->sortable(),
Text::make('Title')->rules('required', 'max:255'),
NovaLarupload::make('Main File', 'main_file'),
];
}
}
That's it, you're ready to go!
Get Attachment Metadata
You can print extracted metadata from your files using NovaLaruploadMeta
field. This field is a read-only field, and it is only used to display metadata.
<?php
namespace App\Nova;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use App\Models\Attachment as Model;
use Mostafaznv\NovaLarupload\Fields\NovaLarupload;
use Mostafaznv\NovaLarupload\Fields\NovaLaruploadMeta;
class Attachment extends Resource
{
public static string $model = Model::class;
public static $title = 'title';
public function fields(NovaRequest $request): array
{
return [
ID::make()->sortable(),
Text::make('Title')->rules('required', 'max:255'),
NovaLarupload::make('Main File', 'main_file'),
// print all metadata
...NovaLaruploadMeta::make('main_file')->all(),
// or print specific metadata
NovaLaruploadMeta::make('main_file')->fileName(),
NovaLaruploadMeta::make('main_file')->size(),
NovaLaruploadMeta::make('main_file')->mimeType(),
NovaLaruploadMeta::make('main_file')->width(),
NovaLaruploadMeta::make('main_file')->height(),
NovaLaruploadMeta::make('main_file')->duration(),
NovaLaruploadMeta::make('main_file')->format(),
];
}
}
I am on an open-source journey 🚀, and I wish I could solely focus on my development path without worrying about my financial situation. However, as life is not perfect, I have to consider other factors.
Therefore, if you decide to use my packages, please kindly consider making a donation. Any amount, no matter how small, goes a long way and is greatly appreciated. 🍺
License
This software is released under The MIT License (MIT).