Creados un monton de componentes para reutilizar en las paginas, modificadas vistas, faltan agregar mas cosas
This commit is contained in:
@@ -16,15 +16,36 @@ class ProductFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$brands = ['Shimano', 'Venzo', 'Trek', 'Specialized', 'Maxxis', 'Sram', 'Raleigh'];
|
||||
$bikeModels = ['Loki', 'Marlin 5', 'Chisel', 'Talon 3', 'Aspect 950'];
|
||||
$accessories = ['Cadena 9v', 'Pedales Aluminio', 'Casco MTB', 'Luz Delantera USB', 'Cámara 29"', 'Cubierta Kevlar'];
|
||||
|
||||
$type = $this->faker->randomElement(['bike', 'accessory', 'service']);
|
||||
|
||||
// Generar nombre según el tipo
|
||||
if ($type === 'bike') {
|
||||
$name = $this->faker->randomElement($brands) . ' ' . $this->faker->randomElement($bikeModels);
|
||||
} elseif ($type === 'accessory') {
|
||||
$name = $this->faker->randomElement($accessories) . ' ' . $this->faker->randomElement(['Pro', 'Basic', 'Comp', 'Elite']);
|
||||
} else {
|
||||
$name = $this->faker->randomElement(['Service General', 'Ajuste Cambios', 'Centrado de Rueda', 'Lavado y Engrase']);
|
||||
}
|
||||
|
||||
// Lógica de Precios
|
||||
$price = $this->faker->numberBetween(5000, 800000);
|
||||
$cost = $price * $this->faker->randomFloat(2, 0.5, 0.7);
|
||||
|
||||
return [
|
||||
'nombre' => $this->faker->sentence(3),
|
||||
'marca'=> $this->faker->randomElement(['Cube','Giant','Megamo','KTM','MMR','Liv','Ghost','Lapierre']),
|
||||
'modelo'=> $this->faker->bothify('????-####'),
|
||||
'rodado'=> $this->faker->numberBetween(12,30),
|
||||
'color'=> $this->faker->safeColorName(),
|
||||
'tipo'=> $this->faker->word(),
|
||||
'descripcion'=> $this->faker->text(),
|
||||
'precio'=> $this->faker->randomFloat(2,100,200)
|
||||
'name' => $name,
|
||||
'sku' => strtoupper($this->faker->bothify('???-#####')),
|
||||
'description' => $this->faker->sentence(10),
|
||||
'price' => $price,
|
||||
'cost' => $cost,
|
||||
'stock_quantity' => $type === 'service' ? 0 : $this->faker->numberBetween(0, 50),
|
||||
'min_stock_alert' => $this->faker->numberBetween(2, 10),
|
||||
'type' => $type,
|
||||
// Nro de serie si es bicicleta
|
||||
'serial_number' => $type === 'bike' ? strtoupper($this->faker->bothify('##??##??')) : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,19 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nombre');
|
||||
$table->string('marca');
|
||||
$table->string('modelo');
|
||||
$table->string('rodado');
|
||||
$table->string('color');
|
||||
$table->string('tipo');
|
||||
$table->text('descripcion');
|
||||
$table->float('precio');
|
||||
$table->string('name');
|
||||
$table->string('sku')->unique()->nullable(); // Código de barras o interno
|
||||
$table->text('description')->nullable();
|
||||
|
||||
$table->decimal('price', 10, 2); // Precio venta
|
||||
$table->decimal('cost', 10, 2)->nullable(); // Costo (solo admin)
|
||||
|
||||
$table->integer('stock_quantity')->default(0);
|
||||
$table->integer('min_stock_alert')->default(5); // Alerta
|
||||
|
||||
$table->enum('type', ['bike', 'accessory', 'service']);
|
||||
$table->string('serial_number')->nullable(); // Solo para bicis
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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('users', function (Blueprint $table) {
|
||||
$table->enum('role', ['admin', 'employee'])->default('employee')->after('email');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('role');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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::create('clients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('phone')->nullable(); // Clave para WhatsApp
|
||||
$table->string('email')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('clients');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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::create('appointments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Si se borra cliente, se borran sus turnos
|
||||
$table->foreignId('client_id')->constrained()->onDelete('cascade');
|
||||
|
||||
$table->dateTime('scheduled_at'); // Fecha y hora del turno
|
||||
$table->string('bike_model');
|
||||
$table->text('problem_description'); // Ej: "Hace ruido la caja"
|
||||
|
||||
$table->enum('status', ['pending', 'confirmed', 'in_progress', 'ready', 'delivered'])
|
||||
->default('pending');
|
||||
|
||||
$table->text('notes')->nullable(); // Notas internas del mecánico
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('appointments');
|
||||
}
|
||||
};
|
||||
@@ -2,26 +2,71 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\User;
|
||||
use App\Models\Product;
|
||||
use App\Models\Client;
|
||||
use App\Models\Appointment;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
User::factory(10)->create();
|
||||
|
||||
//Crear el Super Admin
|
||||
User::factory()->create([
|
||||
'name' => 'admin',
|
||||
'email' => 'admin@laravel.com',
|
||||
'password' => 'admin'
|
||||
'name' => 'Jose Admin',
|
||||
'email' => 'admin@lauck.com',
|
||||
'password' => bcrypt('password'), // Cambiar en producción
|
||||
'role' => 'admin',
|
||||
]);
|
||||
|
||||
Product::factory(50)->create();
|
||||
//Crear un Empleado de prueba
|
||||
User::factory()->create([
|
||||
'name' => 'Empleado Test',
|
||||
'email' => 'taller@lauck.com',
|
||||
'password' => bcrypt('password'),
|
||||
'role' => 'employee',
|
||||
]);
|
||||
|
||||
//Crear Productos
|
||||
Product::create([
|
||||
'name' => 'Cámara 29 Válvula Auto',
|
||||
'sku' => 'CAM-29-A',
|
||||
'price' => 5000,
|
||||
'cost' => 2500,
|
||||
'stock_quantity' => 20,
|
||||
'min_stock_alert' => 5,
|
||||
'type' => 'accessory'
|
||||
]);
|
||||
|
||||
Product::create([
|
||||
'name' => 'Venzo Loki Evo 29',
|
||||
'sku' => 'BIC-VEN-001',
|
||||
'price' => 450000,
|
||||
'cost' => 300000,
|
||||
'stock_quantity' => 2,
|
||||
'min_stock_alert' => 1,
|
||||
'type' => 'bike',
|
||||
'serial_number' => 'VZ998877'
|
||||
]);
|
||||
|
||||
// Generar 10 productos aleatorios más
|
||||
Product::factory(10)->create();
|
||||
|
||||
// Clientes y Turnos
|
||||
$client = Client::create([
|
||||
'name' => 'Juan Perez',
|
||||
'phone' => '1122334455',
|
||||
'email' => 'juan@gmail.com'
|
||||
]);
|
||||
|
||||
Appointment::create([
|
||||
'client_id' => $client->id,
|
||||
'scheduled_at' => now()->addDays(1)->setHour(10)->setMinute(0),
|
||||
'bike_model' => 'Trek Marlin 5',
|
||||
'problem_description' => 'Service completo y ajuste de cambios',
|
||||
'status' => 'pending'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user