PHP code example of mohamedgaldi / vilt-filepond

1. Go to this page and download the library: Download mohamedgaldi/vilt-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/ */

    

mohamedgaldi / vilt-filepond example snippets


// app/Http/Middleware/HandleInertiaRequests.php

public function share(Request $request): array
{
    return [
        ...parent::share($request),
        'user' => fn () => $request->user()
            ? $request->user()->only('name', 'email')
            : null,
        'csrf_token' => csrf_token(),
        'fileUploadConfig' => [
            'locale' => config('vilt-filepond.locale'),
            'chunkSize' => config('vilt-filepond.chunk_size'),
        ],
    ];
}



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use MohamedGaldi\ViltFilepond\Traits\HasFiles;

class Product extends Model
{
    use HasFiles;

    protected $fillable = ['name', 'description'];
}



namespace App\Http\Controllers;

use App\Models\Product;
use Illuminate\Http\Request;
use MohamedGaldi\ViltFilepond\Services\FilePondService;

class ProductController extends Controller
{
    protected FilePondService $filePondService;

    public function __construct(FilePondService $filePondService)
    {
        $this->filePondService = $filePondService;
    }

    public function store(Request $request)
    {
        $request->validate([
            'name' => '            ->with('success', 'Product created successfully!');
    }

    public function update(Request $request, Product $product)
    {
        $request->validate([
            'name' => '



return [
    
    // The disk where files will be stored permanently
    'storage_disk' => 'public',

    // path where temporary files are stored before being moved to permanent location
    'temp_path' => 'temp-files',
    
    // Base path where permanent files are stored
    'files_path' => 'files',
    
    // Files larger than this size (in bytes) will be uploaded in chunks.
    'chunk_size' => 10 * 1024 * 1024, // 10MB
    
    // Configure the FilePond locale. Set to null for English (default).
    // Supported locales: 'ar', 'fr', 'es', null (English)
    'locale' => null,
    
    // Configuration for the package routes
    'routes' => [
        'prefix' => 'filepond',
        'middleware' => ['web'],
    ],
];
bash
# Publish everything at once
php artisan vendor:publish --tag=vilt-filepond

# Or publish individual assets
php artisan vendor:publish --tag=vilt-filepond-config
php artisan vendor:publish --tag=vilt-filepond-migrations
php artisan vendor:publish --tag=vilt-filepond-vue
bash
php artisan migrate
bash
php artisan storage:link