added user seeder

pull/44/head
A1Gard 8 months ago
parent b1f7890866
commit e9595486f7

@ -2,6 +2,7 @@ APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_DEPLOYED=false
APP_TIMEZONE=UTC
APP_URL=http://localhost
@ -19,15 +20,15 @@ LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_LIFETIME=9999999
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

@ -10,6 +10,7 @@ use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
static $roles = ['DEVELOPER','ADMIN','USER'];
/**
* The attributes that are mass assignable.

@ -17,6 +17,9 @@ return new class extends Migration
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('mobile',20)->nullable();
$table->string('avatar',1024)->nullable();
$table->enum('role',\App\Models\User::$roles)->default('USER');
$table->rememberToken();
$table->timestamps();
});

@ -15,9 +15,8 @@ class DatabaseSeeder extends Seeder
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
$this->call(
UserSeeder::class,
);
}
}

@ -0,0 +1,40 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// developer
User::factory()->create(
[
'name' => 'WebDeveloper',
'email' => 'developer@example.com',
'role'=> 'DEVELOPER',
]
);
// website admin
User::factory()->create(
[
'name' => 'Admin',
'email' => 'admin@example.com',
'role'=> 'ADMIN',
]
);
// website user
User::factory()->create(
[
'name' => 'ManagerUser',
'email' => 'user@example.com',
]
);
}
}
Loading…
Cancel
Save