database/seeders/DatabaseSeeder.php
/**
     * Seed the application's database.
     *
     * @return void
     */
Seed the application's database.
@return void
Seed the application ' s database . @return void
public function run()
    {
        $adminRole = Role::create([
            'name' => 'admin',
            'display_name' => 'User Administrator', 
            'description' => 'role is allowed to any thing', 
        ]);
        $admin = User::create([
            'name' => 'admin',
            'password' => bcrypt('123'),
            'email' => 'admin@admin.com'
        ]);
        $admin->attachRole($adminRole);
        $userRole = Role::create([
            'name' => 'user',
            'display_name' => 'User', 
            'description' => 'role is allowed to create , update , delete , comment to Articles', 
        ]);
        $user = User::create([
            'name' => 'user',
            'password' => bcrypt('123'),
            'email' => 'user@user.com'
        ]);
        $user->attachRole($userRole);
        $this->call(CategorySeeder::class);
        $this->call(ArticleSeeder::class);
        $this->call(CommentSeeder::class);
    }
public function run ( ) { $ adminRole = Role :: create ( [ 'name' => 'admin' , 'display_name' => 'User Administrator' , 'description' => 'role is allowed to any thing' , ] ) ; $ admin = User :: create ( [ 'name' => 'admin' , 'password' => bcrypt ( '123' ) , 'email' => 'admin@admin.com' ] ) ; $ admin -> attachRole ( $ adminRole ) ; $ userRole = Role :: create ( [ 'name' => 'user' , 'display_name' => 'User' , 'description' => 'role is allowed to create , update , delete , comment to Articles' , ] ) ; $ user = User :: create ( [ 'name' => 'user' , 'password' => bcrypt ( '123' ) , 'email' => 'user@user.com' ] ) ; $ user -> attachRole ( $ userRole ) ; $ this -> call ( CategorySeeder :: class ) ; $ this -> call ( ArticleSeeder :: class ) ; $ this -> call ( CommentSeeder :: class ) ; }
Seed the application's database.
Seed the application ' s database .
// \App\Models\User::factory(10)->create(); // optional // optional /////////////////////////////////////////////////////////////////////////// // optional // optional /////////////////////////////////////// ////////////////////////////////////// ////////////////////////////////////// //////////////////////////////////////