-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSectorSeeder.php
37 lines (30 loc) · 1.05 KB
/
SectorSeeder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class SectorSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$sectors = json_decode(file_get_contents(base_path("database/data/sectors.json")));
//check if the sector already exists
if (\App\Models\Sector::where('id', $sectors[0]->SectorID)->first()) {
return;
}
foreach ($sectors as $sector) {
\App\Models\Sector::create([
'id' => $sector->SectorID,
'arabic_title' => $sector->ArabicTitle,
'kurdish_title' => $sector->KurdishTitle,
'description' => $sector->Description,
'display_order' => $sector->DisplayOrder,
'display_state' => $sector->DisplayState,
'icon' => $sector->Icon,
'activation_state' => $sector->ActivationState,
]);
}
}
}