67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ServicioSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$contenidoWebId = (int) DB::table('contenidoswebs')->value('id');
|
|
|
|
DB::table('fotos')->updateOrInsert(
|
|
['ruta' => 'images/Servicio.jpg'],
|
|
[
|
|
'extension' => 'jpg',
|
|
'tamanio_bytes' => 0,
|
|
'nombre' => 'Servicio',
|
|
'mime_type' => 'image/jpeg',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]
|
|
);
|
|
|
|
$fotoId = (int) DB::table('fotos')->where('ruta', 'images/Servicio.jpg')->value('id');
|
|
$profesionAbogaciaId = (int) DB::table('profesiones')->where('titulo', 'Abogacía')->value('id');
|
|
|
|
if ($contenidoWebId <= 0 || $fotoId <= 0 || $profesionAbogaciaId <= 0) {
|
|
return;
|
|
}
|
|
|
|
$servicios = [
|
|
[
|
|
'titulo' => 'Consulta jurídica',
|
|
'estado' => 'activo',
|
|
'descripcion' => 'Entrevista para evaluar el caso, orientar al cliente y definir los próximos pasos.',
|
|
'visibleenweb' => 'si',
|
|
'contenidoweb_id' => $contenidoWebId,
|
|
'profesion_id' => $profesionAbogaciaId,
|
|
'foto_id' => $fotoId,
|
|
],
|
|
];
|
|
|
|
foreach ($servicios as $servicio) {
|
|
DB::table('servicios')->updateOrInsert(
|
|
[
|
|
'titulo' => $servicio['titulo'],
|
|
'profesion_id' => $servicio['profesion_id'],
|
|
],
|
|
[
|
|
'estado' => $servicio['estado'],
|
|
'descripcion' => $servicio['descripcion'],
|
|
'visibleenweb' => $servicio['visibleenweb'],
|
|
'contenidoweb_id' => $servicio['contenidoweb_id'],
|
|
'foto_id' => $servicio['foto_id'],
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]
|
|
);
|
|
}
|
|
}
|
|
}
|