Skip to content

Commit

Permalink
Added speedtest seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
henrywhitaker3 committed Apr 10, 2021
1 parent 7b16f1a commit 0b8ccfd
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/Speedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace App;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Speedtest extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*
Expand Down
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
Expand Down
31 changes: 31 additions & 0 deletions database/factories/SpeedtestFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Database\Factories;

use App\Speedtest;
use Illuminate\Database\Eloquent\Factories\Factory;

class SpeedtestFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Speedtest::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'download' => rand(15, 900),
'upload' => rand(15, 900),
'ping' => rand(1, 25),
'scheduled' => (bool) rand(0, 1),
];
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Database\Seeders;

use Database\Seeders\SpeedtestSeeder;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
Expand All @@ -11,6 +14,6 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// $this->call(UserSeeder::class);
$this->call(SpeedtestSeeder::class);
}
}
21 changes: 21 additions & 0 deletions database/seeders/SpeedtestSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Database\Seeders;

use App\Speedtest;
use Illuminate\Database\Seeder;

class SpeedtestSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Speedtest::factory()
->count(250)
->create();
}
}

0 comments on commit 0b8ccfd

Please sign in to comment.