Browse Source

Formulario de Tipo de Vehiculos

le agregamos un pequeño fomulario a tipo de vehiculos relacionado a el tipo de combustible
main
TheSilva7 3 weeks ago
parent
commit
2067a49ef6
  1. 1
      app/Models/tiposVeiculos.php
  2. 1
      database/factories/TiposVeiculosFactory.php
  3. 1
      database/migrations/2025_03_06_162928_create_tipos_veiculos_table.php
  4. 28
      database/migrations/2025_03_13_050724_add_tipo_combustible_to_tipos_veiculos_table.php
  5. 24
      resources/views/vehiculos.blade.php
  6. 24
      resources/views/vehiculosCrearEditar.blade.php

1
app/Models/tiposVeiculos.php

@ -10,5 +10,6 @@ class tiposVeiculos extends Model
use HasFactory;
protected $fillable = [
'nombre',
'tipo_combustible',
];
}

1
database/factories/TiposVeiculosFactory.php

@ -18,6 +18,7 @@ class TiposVeiculosFactory extends Factory
{
return [
"nombre"=> $this->faker->name(),
"Tipo de Combustible"=> $this->faker->sentence(),
//
];
}

1
database/migrations/2025_03_06_162928_create_tipos_veiculos_table.php

@ -14,6 +14,7 @@ return new class extends Migration
Schema::create('tipos_veiculos', function (Blueprint $table) {
$table->id();
$table->string('nombre');
$table->string('tipo_combustible');
$table->timestamps();
});
}

28
database/migrations/2025_03_13_050724_add_tipo_combustible_to_tipos_veiculos_table.php

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('tipos_veiculos', function (Blueprint $table) {
$table->string('tipo_combustible')->after('nombre')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('tipos_veiculos', function (Blueprint $table) {
$table->dropColumn('tipo_combustible');
});
}
};

24
resources/views/vehiculos.blade.php

@ -55,6 +55,7 @@
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Vehículo</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tipo de Combustible</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th>
</tr>
</thead>
@ -66,6 +67,29 @@
<i class="fas fa-car text-blue-500 mr-2"></i>
{{ $vehiculo->nombre }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
@if($vehiculo->tipo_combustible == 'gasolina_verde')
<span class="inline-flex items-center">
<i class="fas fa-gas-pump text-green-500 mr-2"></i>
Gasolina Verde
</span>
@elseif($vehiculo->tipo_combustible == 'gasolina_roja')
<span class="inline-flex items-center">
<i class="fas fa-gas-pump text-red-500 mr-2"></i>
Gasolina Roja
</span>
@elseif($vehiculo->tipo_combustible == 'diesel')
<span class="inline-flex items-center">
<i class="fas fa-gas-pump text-yellow-500 mr-2"></i>
Diesel
</span>
@else
<span class="text-gray-400">
<i class="fas fa-question-circle mr-2"></i>
No especificado
</span>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<div class="flex gap-2">
<a href="#"

24
resources/views/vehiculosCrearEditar.blade.php

@ -63,6 +63,30 @@
@enderror
</div>
<!-- Campo Tipo de Combustible -->
<div>
<label for="tipo_combustible" class="block text-sm font-medium text-gray-700 mb-2">
Tipo de Combustible
</label>
<div class="relative rounded-md shadow-sm">
<select name="tipo_combustible"
id="tipo_combustible"
class="block w-full pl-3 pr-10 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
required>
<option value="">Seleccione un tipo de combustible</option>
<option value="gasolina_verde" {{ isset($tipoVehiculo) && $tipoVehiculo->tipo_combustible == 'gasolina_verde' ? 'selected' : '' }}>Gasolina Verde</option>
<option value="gasolina_roja" {{ isset($tipoVehiculo) && $tipoVehiculo->tipo_combustible == 'gasolina_roja' ? 'selected' : '' }}>Gasolina Roja</option>
<option value="diesel" {{ isset($tipoVehiculo) && $tipoVehiculo->tipo_combustible == 'diesel' ? 'selected' : '' }}>Diesel</option>
</select>
<div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
<i class="fas fa-gas-pump text-gray-400"></i>
</div>
</div>
@error('tipo_combustible')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<!-- Botones de acción -->
<div class="flex justify-end space-x-2 pt-4 border-t border-gray-200">
<a href="{{ route('vehiculos.index') }}"

Loading…
Cancel
Save