PHP code example of moonshine / filepond
1. Go to this page and download the library: Download moonshine/filepond library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moonshine / filepond example snippets
use MoonShine\Filepond\Fields\Filepond;
Filepond::make('Avatar', 'avatar')
->disk('public')
->dir('avatars');
Filepond::make('Gallery', 'images')
->disk('public')
->dir('gallery')
->multiple();
> protected function casts(): array
> {
> return [
> 'images' => 'array', // or 'collection', 'json'
> ];
> }
>
Filepond::make('Documents', 'files')
->disk('public')
->dir('documents')
->multiple()
->acceptExtensions('pdf', 'doc', 'docx');
Filepond::make('Image')
->itemHeight(150) // height: 150px
->itemHeight(150, 50, 200); // height: 150px, min: 50px, max: 200px
Filepond::make('Files')
->multiple()
->vertical();
Filepond::make('Cover')
->aspectRatio('16:9'); // or '1:1', '4:3', etc.
Filepond::make('Thumbnail')
->compact();
use MoonShine\Filepond\Fields\Filepond;
public function fields(): array
{
return [
// Single file with aspect ratio and compact mode
Filepond::make('Thumbnail', 'thumbnail')
->disk('public')
->dir('thumbnails')
->acceptExtensions('jpg', 'jpeg', 'png', 'webp')
->aspectRatio('16:9')
->compact(),
// Multiple files in a grid layout
Filepond::make('Gallery', 'images')
->disk('public')
->dir('gallery')
->multiple()
->itemHeight(180, 100, 200)
->acceptExtensions('jpg', 'jpeg', 'png', 'gif', 'webp'),
// Documents with vertical layout
Filepond::make('Documents', 'documents')
->disk('public')
->dir('documents')
->multiple()
->vertical()
->acceptExtensions('pdf', 'doc', 'docx', 'xls', 'xlsx'),
];
}
bash
php artisan vendor:publish --tag=moonshine-filepond-assets
bash
php artisan vendor:publish --tag=moonshine-filepond-lang
bash
php artisan vendor:publish --tag=moonshine-filepond-lang