Laravel Uploads

PHP MIT

Secure file upload and storage management for Laravel with Eloquent integration, private and public URLs, upload metadata tracking, and Laravel Storage support.

Stars
18
Forks
2
Downloads
2,356
Open Issues
0
Files main

Repository Files

Loading file structure...
database/migrations/create_laravel_uploads_tables.php.stub
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('laravel_uploads_uploads', function (Blueprint $table): void {
            $table->id();
            $table->string('disk');
            $table->string('visibility', 20);
            $table->string('path')->unique();
            $table->string('original_name');
            $table->string('mime_type')->nullable();
            $table->string('extension', 20)->nullable();
            $table->unsignedBigInteger('size')->nullable();
            $table->json('metadata')->nullable();
            $table->timestamps();
        });

        Schema::create('laravel_uploads_links', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('upload_id')->constrained('laravel_uploads_uploads')->cascadeOnDelete();
            $table->string('token', 64)->unique();
            $table->timestamp('expires_at')->nullable();
            $table->timestamp('last_accessed_at')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('laravel_uploads_links');
        Schema::dropIfExists('laravel_uploads_uploads');
    }
};