| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace Database\Seeders;
- use Illuminate\Database\Console\Seeds\WithoutModelEvents;
- use Illuminate\Database\Seeder;
- use App\Models\CheckIn;
- use Illuminate\Support\Facades\File;
- class CheckInSeeder extends Seeder
- {
- /**
- * Run the database seeds.
- *
- * @return void
- */
- public function run()
- {
- CheckIn::truncate();
- $json = File::get("database/MAA.json");
- $child_json = File::get("database/child_count.json");
- $maas = json_decode($json);
- $child = json_decode($child_json);
- foreach ($maas as $key => $value) {
- if ($value->department_id != 'xxx') {
- switch ($value->department_id) {
- case 'B00':
- $region = '南區';
- break;
- case 'B10':
- $region = '中區';
- break;
- default:
- $region = '北區';
- }
- $children_count = isset($child->{$value->user_id}) ? ($child->{$value->user_id}->children_count) : 0;
- CheckIn::create([
- 'user_id' => $value->user_id,
- 'name' => $value->name,
- 'department_id' => $value->department_id,
- 'region' => $region,
- 'is_checked_in' => true,
- 'children_count' => $children_count,
- 'is_awarded' => false,
- 'activity_id' => 2,
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- }
- }
- }
- }
|