Feat: Organize videos by sector

This commit is contained in:
Xavier Oliveira
2026-06-16 12:25:58 +01:00
parent c5ed77945e
commit 84e9bf7307
21 changed files with 477 additions and 116 deletions

View File

@@ -11,13 +11,12 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('refresh_tokens', function (Blueprint $table) {
Schema::create('sectors', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users');
$table->string('token_hash');
$table->dateTime('revoked_at')->nullable();
$table->dateTime('expires_at');
$table->string('name');
$table->string('slug');
$table->timestamps();
$table->boolean('is_active')->default(true);
});
}
@@ -26,6 +25,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('refresh_tokens');
Schema::dropIfExists('sectors');
}
};

View File

@@ -0,0 +1,28 @@
<?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('users', function (Blueprint $table) {
$table->foreignId('sector_id')->nullable()->constrained('sectors');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['sector_id']);
});
}
};

View File

@@ -0,0 +1,29 @@
<?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('video_sector', function (Blueprint $table) {
$table->id();
$table->foreignId('video_id')->constrained()->cascadeOnDelete();
$table->foreignId('sector_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('video_sector');
}
};

View File

@@ -17,6 +17,7 @@ class DatabaseSeeder extends Seeder
$this->call([
RoleSeeder::class,
UserSeeder::class,
SectorsTableSeeder::class,
]);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class SectorsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('sectors')->insert([
'name' => 'Global',
'slug' => 'global',
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
}