Ver código fonte

added better seeding for better update support

AVMG20 4 anos atrás
pai
commit
ef777e22ee

+ 6 - 0
README.md

@@ -118,6 +118,12 @@ command will setup the database tables and then add all of the Nests & Eggs that
 php artisan migrate --seed --force
 ```
 
+### Add some example products
+This step is optional, only run this once
+``` bash
+php artisan db:seed --class=ExampleItemsSeeder --force
+```
+
 ### Add The First User
 ``` bash
 php artisan make:user

+ 21 - 0
database/seeders/ApplicationApiSeeder.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\ApplicationApi;
+use Illuminate\Database\Seeder;
+
+class ApplicationApiSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        ApplicationApi::create([
+            'memo' => 'admin'
+        ]);
+    }
+}

+ 23 - 15
database/seeders/ConfigurationSeeder.php

@@ -15,53 +15,61 @@ class ConfigurationSeeder extends Seeder
     public function run()
     {
         //initials
-        Configuration::create([
-            'key'   => 'INITIAL_CREDITS',
+        Configuration::firstOrCreate([
+            'key' => 'INITIAL_CREDITS',
+        ], [
             'value' => '250',
             'type'  => 'integer',
         ]);
 
-        Configuration::create([
-            'key'   => 'INITIAL_SERVER_LIMIT',
+        Configuration::firstOrCreate([
+            'key' => 'INITIAL_SERVER_LIMIT',
+        ], [
             'value' => '1',
             'type'  => 'integer',
         ]);
 
         //verify email event
-        Configuration::create([
-            'key'   => 'CREDITS_REWARD_AFTER_VERIFY_EMAIL',
+        Configuration::firstOrCreate([
+            'key' => 'CREDITS_REWARD_AFTER_VERIFY_EMAIL',
+        ], [
             'value' => '250',
             'type'  => 'integer',
         ]);
 
-        Configuration::create([
-            'key'   => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL',
+        Configuration::firstOrCreate([
+            'key' => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL',
+        ], [
             'value' => '2',
             'type'  => 'integer',
         ]);
 
         //verify discord event
-        Configuration::create([
+        Configuration::firstOrCreate([
             'key'   => 'CREDITS_REWARD_AFTER_VERIFY_DISCORD',
+        ] , [
             'value' => '375',
             'type'  => 'integer',
         ]);
 
-        Configuration::create([
-            'key'   => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD',
+        Configuration::firstOrCreate([
+            'key' => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD',
+        ], [
             'value' => '2',
             'type'  => 'integer',
         ]);
 
-        Configuration::create([
-            'key'   => 'DISCORD_VERIFY_COMMAND',
+        Configuration::firstOrCreate([
+            'key' => 'DISCORD_VERIFY_COMMAND',
+        ], [
             'value' => '!verify',
             'type'  => 'string',
         ]);
 
         //other
-        Configuration::create([
-            'key'   => 'MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER',
+        Configuration::firstOrCreate([
+            'key' => 'MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER',
+        ], [
             'value' => '50',
             'type'  => 'integer',
         ]);

+ 0 - 2
database/seeders/DatabaseSeeder.php

@@ -15,8 +15,6 @@ class DatabaseSeeder extends Seeder
     {
         $this->call([
             ConfigurationSeeder::class,
-            ProductSeeder::class,
-            PaypalProductSeeder::class,
         ]);
 
     }

+ 23 - 0
database/seeders/ExampleItemsSeeder.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Seeder;
+
+class ExampleItemsSeeder extends Seeder
+{
+    /**
+     * Seed the application's database.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        $this->call([
+            ProductSeeder::class,
+            PaypalProductSeeder::class,
+            ApplicationApiSeeder::class,
+        ]);
+
+    }
+}

+ 3 - 3
database/seeders/ProductSeeder.php

@@ -16,7 +16,7 @@ class ProductSeeder extends Seeder
     {
         Product::create([
             'name' => 'Starter',
-            'description' => '64MB Ram, 1GB Disk, 1 Database, 140 credits p/m',
+            'description' => '64MB Ram, 1GB Disk, 1 Database, 140 credits monthly',
             'price' => 140,
             'memory' => 64,
             'disk' => 1000,
@@ -25,7 +25,7 @@ class ProductSeeder extends Seeder
 
         Product::create([
             'name' => 'Standard',
-            'description' => '128MB Ram, 2GB Disk, 2 Database,  210 credits p/m',
+            'description' => '128MB Ram, 2GB Disk, 2 Database,  210 credits monthly',
             'price' => 210,
             'memory' => 128,
             'disk' => 2000,
@@ -34,7 +34,7 @@ class ProductSeeder extends Seeder
 
         Product::create([
             'name' => 'Advanced',
-            'description' => '256MB Ram, 5GB Disk, 5 Database,  280 credits p/m',
+            'description' => '256MB Ram, 5GB Disk, 5 Database,  280 credits monthly',
             'price' => 280,
             'memory' => 256,
             'disk' => 5000,

+ 0 - 1
routes/api.php

@@ -3,7 +3,6 @@
 use App\Http\Controllers\Api\ServerController;
 use App\Http\Controllers\Api\UserController;
 use App\Http\Controllers\Api\VerifyController;
-use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Route;
 
 /*