Merge pull request #84 from ControlPanel-gg/development_seeding
development seeding
This commit is contained in:
commit
98989c85c7
12 changed files with 124 additions and 6 deletions
33
database/factories/ProductFactory.php
Normal file
33
database/factories/ProductFactory.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ProductFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Product::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'description' => $this->faker->text(60),
|
||||
'price' => $this->faker->numberBetween(0 , 1000),
|
||||
'memory' => $this->faker->numberBetween(32 , 1024),
|
||||
'disk' => $this->faker->numberBetween(500 , 5000),
|
||||
'databases' => $this->faker->numberBetween(1 , 10)
|
||||
];
|
||||
}
|
||||
}
|
34
database/factories/ServerFactory.php
Normal file
34
database/factories/ServerFactory.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ServerFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Server::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'description' => $this->faker->text(60),
|
||||
'identifier' => Str::random(30),
|
||||
'pterodactyl_id' => $this->faker->numberBetween(1000000,1000000000),
|
||||
'product_id' => Product::factory()
|
||||
];
|
||||
}
|
||||
}
|
|
@ -25,7 +25,9 @@ class UserFactory extends Factory
|
|||
return [
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'email_verified_at' => now(),
|
||||
'credits' => $this->faker->numberBetween(0,1500),
|
||||
'last_seen' => $this->faker->dateTimeBetween(now(), '+30 days'),
|
||||
'email_verified_at' => $this->faker->dateTimeBetween('-30 days', now()),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\Seeds\ConfigurationSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
|
21
database/seeders/DevelopmentSeeder.php
Normal file
21
database/seeders/DevelopmentSeeder.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\Seeds\UserSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DevelopmentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call([
|
||||
UserSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\Seeds\ProductSeeder;
|
||||
use Database\Seeders\Seeds\PaypalProductSeeder;
|
||||
use Database\Seeders\Seeds\ApplicationApiSeeder;
|
||||
use Database\Seeders\Seeds\UsefulLinksSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ExampleItemsSeeder extends Seeder
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Seeds;
|
||||
|
||||
use App\Models\ApplicationApi;
|
||||
use Illuminate\Database\Seeder;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Seeds;
|
||||
|
||||
use App\Models\Configuration;
|
||||
use Illuminate\Database\Seeder;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Seeds;
|
||||
|
||||
use App\Models\PaypalProduct;
|
||||
use Illuminate\Database\Seeder;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Seeds;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Seeder;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Seeds;
|
||||
|
||||
use App\Models\UsefulLink;
|
||||
use Illuminate\Database\Seeder;
|
23
database/seeders/Seeds/UserSeeder.php
Normal file
23
database/seeders/Seeds/UserSeeder.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Seeds;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
User::factory()
|
||||
->count(10)
|
||||
->has(Server::factory()->count(rand(1,3)) , 'servers')
|
||||
->create();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue