Skip to content
43 changes: 0 additions & 43 deletions database/seeders/BackstageSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Backstage\Models\Language;
use Backstage\Models\Site;
use Backstage\Models\Type;
use Backstage\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -173,47 +172,5 @@ public function run(): void
(string) Str::uuid() => ['type' => 'form', 'data' => ['slug' => 'contact']],
]),
]), 'values')->create();

User::factory([
'name' => 'Mark',
'email' => 'mark@vk10.nl',
'password' => 'mark@vk10.nl',
])->create();

User::factory([
'name' => 'Rob',
'email' => 'rob@vk10.nl',
'password' => 'rob@vk10.nl',
])->create();

User::factory([
'name' => 'Mathieu',
'email' => 'mathieu@vk10.nl',
'password' => 'mathieu@vk10.nl',
])->create();

User::factory([
'name' => 'Bas',
'email' => 'bas@vk10.nl',
'password' => 'bas@vk10.nl',
])->create();

User::factory([
'name' => 'Yoni',
'email' => 'yoni@vk10.nl',
'password' => 'yoni@vk10.nl',
])->create();

User::factory([
'name' => 'Patrick',
'email' => 'patrick@vk10.nl',
'password' => 'patrick@vk10.nl',
])->create();

User::factory([
'name' => 'Sandro',
'email' => 'sandro@vk10.nl',
'password' => 'sandro@vk10.nl',
])->create();
}
}
110 changes: 15 additions & 95 deletions packages/core/src/BackstageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Backstage\Commands\BackstageUpgrade;
use Backstage\CustomFields\Builder;
use Backstage\CustomFields\CheckboxList;
use Backstage\Database\Factories\UserFactory;
use Backstage\Events\FormSubmitted;
use Backstage\Http\Middleware\SetLocale;
use Backstage\Listeners\ExecuteFormActions;
Expand Down Expand Up @@ -66,18 +67,12 @@ public function configurePackage(Package $package): void
->startWith(function (InstallCommand $command) {
$command->info('Welcome to the Backstage setup process.');
$command->comment("Don't trip over the wires; this is where the magic happens.");
$command->comment('Let\'s get started!');
$command->comment("Let's get started!");

// if ($command->confirm('Would you like us to install Backstage for you?', true)) {
$command->comment('Lights, camera, action! Setting up for the show...');

$command->comment('Preparing stage...');

$command->callSilently('vendor:publish', [
'--tag' => 'translations-config',
'--force' => true,
]);

$command->callSilently('vendor:publish', [
'--tag' => 'backstage-config',
'--force' => true,
Expand All @@ -87,8 +82,6 @@ public function configurePackage(Package $package): void

$this->writeMediaPickerConfig();

$this->writeTranslationsConfig();

$command->callSilently('vendor:publish', [
'--tag' => 'backstage-migrations',
'--force' => true,
Expand Down Expand Up @@ -120,12 +113,23 @@ public function configurePackage(Package $package): void
$path = app()->environmentFilePath();
file_put_contents($path, file_get_contents($path) . PHP_EOL . $key . '=' . $value);

if ($command->confirm('Would you like to create a user?', true)) {
$command->comment('Our next performer is...');
$user = $command->ask('Your name?');
$email = $command->ask('Your email?');
$password = $command->ask('Your password?');
UserFactory::create([
'name' => $user,
'email' => $email,
'password' => $password,
]);
}

$command->comment('Raise the curtain...');
// }
})
->endWith(function (InstallCommand $command) {
$command->info('The stage is cleared for a fresh start');
$command->comment('You can now go on stage and start creating!');
$command->comment('You can now go on stage (/backstage) and start creating!');
})
->askToStarRepoOnGitHub('backstage/cms');
});
Expand Down Expand Up @@ -408,90 +412,6 @@ private function writeMediaPickerConfig(?string $path = null): void
file_put_contents($path, $configContent);
}

private function generateTranslationsConfig(): array
{
$config = [
'scan' => [
'paths' => [
app_path(),
resource_path('views'),
base_path(''),
],

'extensions' => [
'*.php',
'*.blade.php',
'*.json',
],

'functions' => [
'trans',
'trans_choice',
'Lang::transChoice',
'Lang::trans',
'Lang::get',
'Lang::choice',
'@lang',
'@choice',
'__',
],
],

'eloquent' => [
'translatable-models' => [
\Backstage\Models\ContentFieldValue::class,
\Backstage\Models\Tag::class,
],
],

'translators' => [
'default' => env('TRANSLATION_DRIVER', 'google-translate'),

'drivers' => [
'google-translate' => [
// no options
],

'ai' => [
'provider' => \Prism\Prism\Enums\Provider::OpenAI,
'model' => 'gpt-5',
'system_prompt' => 'You are an expert mathematician who explains concepts simply. The only thing you do it output what i ask. No comments, no extra information. Just the answer.',
],

'deep-l' => [
//
],
],
],
];

config(['translations' => $config]);

return $config;
}

private function writeTranslationsConfig(?string $path = null): void
{
$path ??= config_path('translations.php');

// Ensure directory exists
$directory = dirname($path);
if (! is_dir($directory)) {
mkdir($directory, 0755, true);
}

// Generate the config file content
$configContent = "<?php\n\n";
$configContent .= "use Backstage\Models\Tag;\n";
$configContent .= "use Prism\Prism\Enums\Provider;\n";
$configContent .= "use Backstage\Models\ContentFieldValue;\n\n";

// Custom export function to create more readable output
$configContent .= 'return ' . $this->customVarExport($this->generateTranslationsConfig()) . ";\n";

file_put_contents($path, $configContent);
}

private function customVarExport($var, $indent = ''): string
{
switch (gettype($var)) {
Expand Down