Skip to content
Snippets Groups Projects
Commit 4b7d7120 authored by Shizuco's avatar Shizuco
Browse files

feat: seed/migration for users

parent b8c6ae0d
No related branches found
No related tags found
No related merge requests found
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
User::create([
'name' => 'admin',
'email' => 'admin@groupbwt.com',
'role' => 'admin',
'password' => Hash::make('12345678')
]);
}
};
<?php
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
// \App\Models\User::factory(10)->create();
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
\App\Models\User::factory()->create([
'name' => Str::random(10),
'email' => Str::random(10).'@gmail.com',
'password' => Hash::make('password'),
'role' => 'analyst'
]);
\App\Models\User::factory()->create([
'name' => Str::random(10),
'email' => Str::random(10).'@gmail.com',
'password' => Hash::make('password'),
'role' => 'common'
]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment