%PDF- %PDF-
Direktori : /var/www/html/hrsys/api/database/seeds/ |
Current File : /var/www/html/hrsys/api/database/seeds/DatabaseSeeder.php |
<?php use App\Models\BaseModel; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; class DatabaseSeeder extends Seeder { /** * Seed the application's database. * * @return void */ public function run() { DB::statement('SET FOREIGN_KEY_CHECKS=0'); $this->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1'); $this->call(PassportSetup::class); $this->call(ConfigurationsTableSeeder::class); $this->call(DaysTableSeeder::class); $this->call(HolidaysTableSeeder::class); $this->call(WorkingDaysTableSeeder::class); $this->call(RolesTableSeeder::class); $this->call(UsersTableSeeder::class); $this->call(ClientsTableSeeder::class); $this->call(ProjectsTableSeeder::class); $this->call(TimecardsTableSeeder::class); BaseModel::createPaths(); } private function truncate() { $tables_in_db = DB::select('SHOW TABLES'); $db = "Tables_in_" . env('DB_DATABASE'); $tables = []; foreach ($tables_in_db as $table) { $tables[] = $table->{$db}; } foreach ($tables as $table) { if ($table !== 'migrations') { DB::table($table) ->truncate(); } } } }