Add
This commit is contained in:
@@ -5,6 +5,8 @@ namespace Database\Seeders;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
@@ -15,11 +17,34 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
$roles = ['admin', 'provider', 'buyer'];
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
foreach ($roles as $role) {
|
||||
Role::findOrCreate($role);
|
||||
}
|
||||
|
||||
$admin = User::updateOrCreate(
|
||||
['email' => 'admin@example.com'],
|
||||
['name' => 'Admin User', 'password' => Hash::make('password')]
|
||||
);
|
||||
$admin->syncRoles(['admin']);
|
||||
|
||||
$provider = User::updateOrCreate(
|
||||
['email' => 'provider@example.com'],
|
||||
['name' => 'Provider User', 'password' => Hash::make('password')]
|
||||
);
|
||||
$provider->syncRoles(['provider']);
|
||||
|
||||
$buyer = User::updateOrCreate(
|
||||
['email' => 'buyer@example.com'],
|
||||
['name' => 'Buyer User', 'password' => Hash::make('password')]
|
||||
);
|
||||
$buyer->syncRoles(['buyer']);
|
||||
|
||||
$hybrid = User::updateOrCreate(
|
||||
['email' => 'hybrid@example.com'],
|
||||
['name' => 'Hybrid User', 'password' => Hash::make('password')]
|
||||
);
|
||||
$hybrid->syncRoles(['provider', 'buyer']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user