Admin can now control channel creation from the admin dashboard

This commit is contained in:
2026-05-16 03:43:25 +03:30
parent 34445f3032
commit f46f32aa4c
14 changed files with 639 additions and 95 deletions

View File

@@ -0,0 +1,22 @@
<?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::table('users', function (Blueprint $table) {
$table->boolean('can_create_channel')->default(false)->index()->after('is_admin');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('can_create_channel');
});
}
};

View File

@@ -0,0 +1,22 @@
<?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('platform_settings', function (Blueprint $table) {
$table->id();
$table->boolean('channel_creation_open')->default(false);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('platform_settings');
}
};

View File

@@ -3,7 +3,9 @@
namespace Database\Seeders;
use App\Models\Category;
use App\Models\PlatformSetting;
use App\Models\User;
use App\Services\Streaming\StreamKeyManager;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
@@ -24,15 +26,35 @@ class DatabaseSeeder extends Seeder
['name' => $category['name']],
));
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
PlatformSetting::current();
$admin = User::query()->firstOrNew(['email' => 'admin@nyone.net']);
$admin->forceFill([
'name' => 'Admin User',
'password' => 'password',
'email_verified_at' => now(),
'is_admin' => true,
'can_create_channel' => false,
])->save();
$official = User::query()->firstOrNew(['email' => 'chief@nyone.net']);
$official->forceFill([
'name' => 'Chief Nyone',
'password' => 'password',
'email_verified_at' => now(),
'is_admin' => false,
'can_create_channel' => true,
])->save();
$channel = $official->channel()->updateOrCreate([], [
'category_id' => Category::query()->where('slug', 'creative')->value('id'),
'slug' => 'nyone',
'display_name' => 'Nyone Official',
'description' => 'Official updates and live sessions from Nyone.',
]);
User::factory()->create([
'name' => 'Admin User',
'email' => 'admin@example.com',
'is_admin' => true,
]);
if (! $channel->streamKey()->exists()) {
app(StreamKeyManager::class)->rotate($channel);
}
}
}