Skip to content

Commit

Permalink
[ADD] Base database structure seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-astral-cat committed Sep 6, 2023
1 parent 546cd8a commit b255dca
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
35 changes: 35 additions & 0 deletions database/seeders/BoardSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Database\Seeders;

use App\Models\Board;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class BoardSeeder extends Seeder
{
use WithoutModelEvents;

/**
* Run the database seeds.
*/
public function run(): void
{
Board::create([
'uuid' => 'FCDR567NAK7U',
'name' => 'Main classroom',
'ip' => '192.168.2.56',
'last_seen' => now(),
]);
Board::create([
'uuid' => 'FXXGFSK8HG35',
'name' => 'Telecomunications room',
'ip' => '192.168.2.67',
'last_seen' => now(),
]);
Board::create([
'uuid' => 'FCDR567NAK7U',
'name' => 'Main classroom',
]);
}
}
4 changes: 4 additions & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public function run(): void
$this->call([
RoleSeeder::class,
UserSeeder::class,
BoardSeeder::class,
ProfileSeeder::class,
SessionSeeder::class,
MeasurementSeeder::class,
]);
}
}
57 changes: 57 additions & 0 deletions database/seeders/MeasurementSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Database\Seeders;

use App\Models\Measurement;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class MeasurementSeeder extends Seeder
{
use WithoutModelEvents;

/**
* Run the database seeds.
*/
public function run(): void
{
$temp = 20;
$gradient = 2;
//Make ramp to soak
for ($i = 1; $i <= 40; $i++) {
Measurement::create([
'session_id' => 1,
'temperature' => $temp,
'sequence' => $i,
]);
$temp += $gradient;
}
//Now we make soak time
for ($i = 41; $i <= 140; $i++) {
Measurement::create([
'session_id' => 1,
'temperature' => $temp,
'sequence' => $i,
]);
}
$gradient = 5; //ramp up gradient to peak
for ($i = 141; $i < 158; $i++) {
Measurement::create([
'session_id' => 1,
'temperature' => $temp,
'sequence' => $i,
]);
$temp += $gradient;
}
//Cool down ramp
$gradient = -6;
for ($i = 158; $i <= 185; $i++) {
Measurement::create([
'session_id' => 1,
'temperature' => $temp,
'sequence' => $i,
]);
$temp += $gradient;
}
}
}
39 changes: 39 additions & 0 deletions database/seeders/ProfileSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Database\Seeders;

use App\Models\Profile;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class ProfileSeeder extends Seeder
{
use WithoutModelEvents;

/**
* Run the database seeds.
*/
public function run(): void
{
Profile::create([
'name' => 'Eutetic',
'soak_time' => 70,
'soak_temperature' => 100,
'reflow_gradient' => 2,
'reflow_peak_temp' => 183,
'reflow_max_time' => 120,
'ramp_up_gradient' => 5,
'cooldown_gradient' => -6,
]);
Profile::create([
'name' => 'Lead free',
'soak_time' => 90,
'soak_temperature' => 120,
'reflow_gradient' => 4,
'reflow_peak_temp' => 210,
'reflow_max_time' => 150,
'ramp_up_gradient' => 6,
'cooldown_gradient' => -5,
]);
}
}
42 changes: 42 additions & 0 deletions database/seeders/SessionSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Database\Seeders;

use App\Models\Session;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class SessionSeeder extends Seeder
{
use WithoutModelEvents;

/**
* Run the database seeds.
*/
public function run(): void
{
Session::create([
'board_id' => 1,
'date' => Carbon::now()->subDays(5),
'soak_time' => 70,
'soak_temperature' => 100,
'reflow_gradient' => 2,
'reflow_peak_temp' => 183,
'reflow_max_time' => 120,
'ramp_up_gradient' => 5,
'cooldown_gradient' => -6,
]);
Session::create([
'board_id' => 1,
'date' => Carbon::now()->subDays(2),
'soak_time' => 90,
'soak_temperature' => 120,
'reflow_gradient' => 4,
'reflow_peak_temp' => 210,
'reflow_max_time' => 150,
'ramp_up_gradient' => 6,
'cooldown_gradient' => -5,
]);
}
}

0 comments on commit b255dca

Please sign in to comment.