Skip to content

Commit 2a26798

Browse files
author
Morten Bak
committed
change up seeders
1 parent 1e858c8 commit 2a26798

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

database/seeders/DatabaseSeeder.php

+1-18
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,7 @@ public function run(): void
1717
$this->call([
1818
RoleSeeder::class,
1919
PermissionSeeder::class,
20-
]);
21-
22-
$user = User::create([
23-
'name' => 'Admin',
24-
'email' => '[email protected]',
25-
'password' => bcrypt('password'),
26-
]);
27-
$user->assignRole('Super Admin');
28-
29-
Plan::query()->create([
30-
'title' => 'Pro - 39 DKK / måned',
31-
'slug' => 'pro-monthly',
32-
'stripe_id' => 'price_1M9oZfKePSHD5WYkw7y8wq1R',
33-
]);
34-
Plan::query()->create([
35-
'title' => 'Pro - 399 DKK / år',
36-
'slug' => 'pro-yearly',
37-
'stripe_id' => 'price_1M9oZfKePSHD5WYk4ZM245Hv',
20+
PlanSeeder::class,
3821
]);
3922
}
4023
}

database/seeders/PlanSeeder.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Database\Seeders;
4+
5+
use App\Models\Plan;
6+
use Illuminate\Database\Seeder;
7+
8+
class PlanSeeder extends Seeder
9+
{
10+
/**
11+
* Run the database seeds.
12+
*/
13+
public function run(): void
14+
{
15+
if (!Plan::query()->where('slug', '=', 'pro-monthly')->exists()) {
16+
Plan::query()->create([
17+
'title' => 'Pro - 39 DKK / måned',
18+
'slug' => 'pro-monthly',
19+
'stripe_id' => 'price_1M9oZfKePSHD5WYkw7y8wq1R',
20+
]);
21+
}
22+
if (!Plan::query()->where('slug', '=', 'pro-yearly')->exists()) {
23+
Plan::query()->create([
24+
'title' => 'Pro - 399 DKK / år',
25+
'slug' => 'pro-yearly',
26+
'stripe_id' => 'price_1M9oZfKePSHD5WYk4ZM245Hv',
27+
]);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)