faker = Faker\Factory::create(); } /** * Execute the console command. * * @return int */ public function handle() { $this->info('Setting up development environment'); $this->migrate_and_generate(); $this->store_data(); $this->seed_default_content(); $this->create_admin(); $this->clear_cache(); $this->info('Everything is done, congratulations! 🥳🥳🥳'); } /** * Create default admin account */ private function create_admin(): void { $user = User::forceCreate([ 'role' => 'admin', 'name' => 'John Doe', 'email' => 'john@doe.com', 'password' => Hash::make('secret'), ]); $user ->settings() ->create([ 'storage_capacity' => 5, 'name' => 'John Doe', 'address' => $this->faker->address, 'state' => $this->faker->state, 'city' => $this->faker->city, 'postal_code' => $this->faker->postcode, 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), 'phone_number' => $this->faker->phoneNumber, 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), ]); // Show user credentials $this->info('Default admin account created. Email: john@doe.com and Password: secret'); } /** * Seed default content to database */ private function seed_default_content(): void { collect(config('content.content')) ->each(function ($content) { Setting::updateOrCreate($content); }); collect(config('content.pages')) ->each(function ($page) { Page::updateOrCreate($page); }); } /** * Store main app settings into database */ private function store_data(): void { // Get options $settings = collect([ [ 'name' => 'setup_wizard_database', 'value' => 1, ], [ 'name' => 'app_title', 'value' => 'VueFileManager', ], [ 'name' => 'app_description', 'value' => 'Your self-hosted storage cloud software powered by Laravel and Vue', ], [ 'name' => 'app_logo', 'value' => null, ], [ 'name' => 'app_logo_horizontal', 'value' => null, ], [ 'name' => 'app_favicon', 'value' => null, ], [ 'name' => 'google_analytics', 'value' => '', ], [ 'name' => 'contact_email', 'value' => '', ], [ 'name' => 'registration', 'value' => 1, ], [ 'name' => 'storage_limitation', 'value' => 1, ], [ 'name' => 'storage_default', 'value' => 5, ], [ 'name' => 'setup_wizard_success', 'value' => 1, ], [ 'name' => 'license', 'value' => 'Extended', ], [ 'name' => 'purchase_code', 'value' => '26b889eb-3602-4bf2-beb3-3sc378fcf484', ] ]); // Store options $settings->each(function ($col) { Setting::updateOrCreate(['name' => $col['name']], $col); }); } /** * Migrate database and generate application keys */ private function migrate_and_generate(): void { // Generate app key $this->call('key:generate', [ '--force' => true ]); // Migrate database $this->call('migrate:fresh', [ '--force' => true ]); } /** * Clear app cache */ private function clear_cache(): void { $this->call('cache:clear'); $this->call('config:clear'); $this->call('view:clear'); } }