78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Modules\Admin\Database\seeders;
|
||
|
|
||
|
use Modules\Admin\App\Models\User;
|
||
|
use Illuminate\Http\UploadedFile;
|
||
|
use Illuminate\Support\Facades\Storage;
|
||
|
use Illuminate\Database\Seeder;
|
||
|
|
||
|
class UserSeeder extends Seeder
|
||
|
{
|
||
|
/**
|
||
|
* Run the database seeds.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function run()
|
||
|
{
|
||
|
// Define el disco y la carpeta
|
||
|
$disk = 'public';
|
||
|
$directory = 'profile-photos';
|
||
|
|
||
|
// Verifica si la carpeta existe
|
||
|
if (Storage::disk($disk)->exists($directory))
|
||
|
Storage::disk($disk)->deleteDirectory($directory);
|
||
|
|
||
|
// Arturo Corro
|
||
|
$user = User::create([
|
||
|
'name' => 'Koneko Admin',
|
||
|
'email' => 'admin@koneko.mx',
|
||
|
'email_verified_at' => now(),
|
||
|
'password' => bcrypt('LAdmin123'),
|
||
|
'status' => User::STATUS_ENABLED,
|
||
|
])->assignRole('SuperAdmin');
|
||
|
|
||
|
$user->updateProfilePhoto(new UploadedFile(
|
||
|
'public/assets/img/logo/koneko-02.png',
|
||
|
'koneko-02.png'
|
||
|
));
|
||
|
|
||
|
|
||
|
// Webmaster admin
|
||
|
$user = User::create([
|
||
|
'name' => 'Admin',
|
||
|
'email' => 'servers@koneko.mx',
|
||
|
'email_verified_at' => now(),
|
||
|
'password' => bcrypt('LAdmin123'),
|
||
|
'status' => User::STATUS_ENABLED,
|
||
|
])->assignRole('Admin');
|
||
|
|
||
|
$user->updateProfilePhoto(new UploadedFile(
|
||
|
'public/assets/img/logo/koneko-03.png',
|
||
|
'koneko-03.png'
|
||
|
));
|
||
|
|
||
|
// Usuarios CSV
|
||
|
$csvFile = fopen(base_path("modules/Admin/Database/data/users.csv"), "r");
|
||
|
|
||
|
$firstline = true;
|
||
|
|
||
|
while (($data = fgetcsv($csvFile, 2000, ",")) !== FALSE) {
|
||
|
if (!$firstline) {
|
||
|
User::create([
|
||
|
'name' => $data['0'],
|
||
|
'email' => $data['1'],
|
||
|
'email_verified_at' => now(),
|
||
|
'password' => bcrypt($data['3']),
|
||
|
'status' => User::STATUS_ENABLED,
|
||
|
])->assignRole($data['2']);
|
||
|
}
|
||
|
|
||
|
$firstline = false;
|
||
|
}
|
||
|
|
||
|
fclose($csvFile);
|
||
|
}
|
||
|
}
|