39 lines
937 B
PHP
39 lines
937 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Seeders;
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||
|
|
use Illuminate\Database\Seeder;
|
||
|
|
use Illuminate\Support\Facades\Hash;
|
||
|
|
|
||
|
|
class UserSeeder extends Seeder
|
||
|
|
{
|
||
|
|
use WithoutModelEvents;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Run the database seeds.
|
||
|
|
*/
|
||
|
|
public function run(): void
|
||
|
|
{
|
||
|
|
// TP7 et TP8 : deux comptes permettent de comparer authentification et autorisation.
|
||
|
|
User::updateOrCreate(
|
||
|
|
['email' => 'jean@example.com'],
|
||
|
|
[
|
||
|
|
'name' => 'Jean Dupont',
|
||
|
|
'password' => Hash::make('password123'),
|
||
|
|
'is_admin' => true,
|
||
|
|
],
|
||
|
|
);
|
||
|
|
|
||
|
|
User::updateOrCreate(
|
||
|
|
['email' => 'marie@example.com'],
|
||
|
|
[
|
||
|
|
'name' => 'Marie Martin',
|
||
|
|
'password' => Hash::make('password123'),
|
||
|
|
'is_admin' => false,
|
||
|
|
],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|