-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\Asset; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class AssetFactory extends Factory | ||
{ | ||
protected $model = Asset::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
'name' => $this->faker->word, | ||
'price' => $this->faker->randomDigitNotNull() * 100000, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\SolarHomeSystem; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class SolarHomeSystemFactory extends Factory | ||
{ | ||
protected $model = SolarHomeSystem::class; | ||
|
||
public function definition(): array | ||
{ | ||
return [ | ||
// 'asset_id' => 1, | ||
'serial_number' => $this->faker->unique()->uuid, | ||
'manufacturer_id' => 1, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\Asset; | ||
use App\Models\AssetType; | ||
use App\Models\Device; | ||
use App\Models\Manufacturer; | ||
use App\Models\SolarHomeSystem; | ||
use Illuminate\Database\Seeder; | ||
use MPM\DatabaseProxy\DatabaseProxyManagerService; | ||
|
||
class SolarHomeSystemSeeder extends Seeder | ||
{ | ||
public function __construct( | ||
private DatabaseProxyManagerService $databaseProxyManagerService, | ||
) { | ||
$this->databaseProxyManagerService->buildDatabaseConnectionDummyCompany(); | ||
} | ||
|
||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
// Manufacturer | ||
// For now, we just adding some dummy Manufacturers. | ||
// Later, this should probably be synced with the manufacturers | ||
// for which we have plugins in the Demo setup. | ||
$manufacturers = Manufacturer::factory() | ||
->count(2) | ||
->isShsManufacturer() | ||
->create(); | ||
|
||
// Get the SHS asset type | ||
$assetType = AssetType::where('name', 'Solar Home System')->first(); | ||
|
||
// Create our appliances, i.e. sales deals (?) | ||
$appliances = Asset::factory() | ||
->count(5) | ||
->for($assetType) | ||
->sequence( | ||
// Thank you ChatGPT for generating these names... 🤖 | ||
[ | ||
'name' => 'SunPower Home 3000', | ||
'price' => 500000, | ||
], | ||
[ | ||
'name' => 'SunPower Home 1000', | ||
'price' => 100000, | ||
], | ||
['name' => 'EcoBright Solar Kit'], | ||
['name' => 'HelioVolt Pro Series'], | ||
['name' => 'SolaraMax Home Energy'], | ||
) | ||
->create(); | ||
|
||
// Create not-yet-sold SHS such that we can "sell" them in the Demo | ||
for ($i = 1; $i <= 10; ++$i) { | ||
$solarHomeSystem = SolarHomeSystem::factory() | ||
->for(Asset::all()->random(), 'appliance') | ||
->for(Manufacturer::where('type', 'shs')->get()->random()) | ||
->create(); | ||
|
||
$device = Device::factory() | ||
->for($solarHomeSystem, 'device') | ||
->create([ | ||
'device_serial' => $solarHomeSystem->serial_number, | ||
]); | ||
} | ||
|
||
// Create already-sold SHS | ||
$sold_solar_home_systems = null; | ||
|
||
// TBD: assign appliances to Agents | ||
// This is required to use the Agent app. | ||
} | ||
} |