feat: add media

This commit is contained in:
2025-11-24 18:59:26 +03:30
parent 992a7959fa
commit fef81022fa
8 changed files with 1282 additions and 768 deletions
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('media', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('image_id')->nullable();
$table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('user_id')->nullable(); // owner (optional)
$table->string('title');
$table->text('caption')->nullable();
// media type (audio / video)
$table->enum('type', ['audio', 'video']);
// File or URL
$table->string('file_path')->nullable(); // stored file
$table->string('external_url')->nullable(); // YouTube, etc.
$table->integer('duration')->nullable(); // seconds
// public/private
$table->enum('visibility', ['public', 'private'])->default('public');
$table->timestamps();
$table->foreign('image_id')->references('id')->on('images')->nullOnDelete();
$table->foreign('category_id')->references('id')->on('categories')->nullOnDelete();
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('media');
}
};