feat: add media
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
<?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::table('user_product', function (Blueprint $table) {
|
||||
$table->renameColumn('subscription_token' ,'gateway');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('user_product', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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('saved_media', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('media_id');
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['media_id', 'user_id']);
|
||||
$table->foreign('media_id')->references('id')->on('media')->cascadeOnDelete();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('saved_media');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user