Files
firefly-iii/database/seeds/TestDataSeeder.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2015-02-06 04:41:00 +01:00
<?php
2016-02-05 15:01:33 +01:00
declare(strict_types = 1);
/**
* TestDataSeeder.php
2016-04-01 16:46:11 +02:00
* Copyright (C) 2016 thegrumpydictator@gmail.com
2016-02-05 15:01:33 +01:00
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
2016-01-16 09:15:24 +01:00
2016-01-30 07:36:11 +01:00
use FireflyIII\Support\Migration\TestData;
2015-02-11 07:35:10 +01:00
use Illuminate\Database\Seeder;
2015-02-06 04:41:00 +01:00
/**
* Class TestDataSeeder
*/
class TestDataSeeder extends Seeder
{
2016-01-24 20:38:58 +01:00
/**
* TestDataSeeder constructor.
*/
public function __construct()
{
}
2015-02-06 04:41:00 +01:00
/**
2016-01-16 09:15:24 +01:00
* Run the database seeds.
2015-06-29 15:23:50 +02:00
*
2016-01-16 09:15:24 +01:00
* @return void
2015-02-06 04:41:00 +01:00
*/
public function run()
{
2016-05-15 15:01:29 +02:00
$disk = Storage::disk('database');
$env = App::environment();
Log::debug('Environment is ' . $env);
2016-05-14 21:49:16 +02:00
$fileName = 'seed.' . $env . '.json';
if ($disk->exists($fileName)) {
2016-05-15 15:01:29 +02:00
Log::debug('Now seeding ' . $fileName);
2016-05-14 21:49:16 +02:00
$file = json_decode($disk->get($fileName), true);
// run the file:
TestData::run($file);
2016-05-15 15:01:29 +02:00
return;
2016-02-05 15:01:33 +01:00
}
2016-05-15 15:01:29 +02:00
Log::info('No seed file (' . $fileName . ') for environment ' . $env);
2016-01-20 10:47:29 +01:00
}
2015-03-29 08:14:32 +02:00
}