34 lines
		
	
	
	
		
			871 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			871 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use App\GrupoDeCompra;
 | 
						|
use App\User;
 | 
						|
use App\UserRole;
 | 
						|
use Illuminate\Database\Seeder;
 | 
						|
use Illuminate\Support\Facades\Hash;
 | 
						|
 | 
						|
class UsuarioOllasSeeder extends Seeder
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Run the database seeds.
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function run()
 | 
						|
    {
 | 
						|
        $barrios = GrupoDeCompra::all();
 | 
						|
        $usersToInsert = [];
 | 
						|
        $ollas_id = UserRole::where('nombre', 'ollas')->first()->id;
 | 
						|
 | 
						|
        foreach ($barrios as $barrio) {
 | 
						|
            $usersToInsert[] = DatabaseSeeder::addTimestamps([
 | 
						|
                'name' => $barrio->nombre . '_ollas',
 | 
						|
                'password' => Hash::make('123'),
 | 
						|
                'role_id' => $ollas_id,
 | 
						|
                'grupo_de_compra_id' => $barrio->id,
 | 
						|
            ]);
 | 
						|
        }
 | 
						|
 | 
						|
        foreach (array_chunk($usersToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)
 | 
						|
            User::insert($chunk);
 | 
						|
    }
 | 
						|
}
 |