Merge branch 'bryam' of https://github.com/BryamE/ProyectoLauck into giane
This commit is contained in:
@@ -13,4 +13,28 @@ class CatalogoController extends Controller
|
|||||||
$productos = Product::all();
|
$productos = Product::all();
|
||||||
return view('catalogo', compact('productos'));
|
return view('catalogo', compact('productos'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Muestra los registros de ventas con buscador y paginación.
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
// Recuperamos lo que el usuario escribió en el buscador (si escribió algo)
|
||||||
|
$query = $request->input('search');
|
||||||
|
// Recuperamos el filtro aplicado (si aplica)
|
||||||
|
$filter = $request->input('filter');
|
||||||
|
|
||||||
|
// Construimos la consulta
|
||||||
|
$sales = Product::query()
|
||||||
|
->when($query, function ($q) use ($query) {
|
||||||
|
// Si hay búsqueda, filtra por nombre o SKU
|
||||||
|
return $q->where('name', 'like', "%{$query}%")
|
||||||
|
->orWhere('sku', 'like', "%{$query}%");
|
||||||
|
})
|
||||||
|
->orderBy('stock_quantity', 'asc') // Ordenamos primero los que tienen poco stock (Alerta visual)
|
||||||
|
->paginate(10) // Paginamos de a 10
|
||||||
|
->withQueryString(); // Mantiene el filtro de búsqueda al cambiar de página
|
||||||
|
|
||||||
|
return view('sales', compact('sales'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,67 +4,136 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule; // Necesario para validar unicidad al editar
|
||||||
|
|
||||||
class ProductosController extends Controller
|
class ProductosController extends Controller
|
||||||
{
|
{
|
||||||
public function index(){
|
/**
|
||||||
$products = Product::orderBy('id','desc')->paginate();
|
* Muestra la lista de productos con buscador y paginación.
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
// Recuperamos lo que el usuario escribió en el buscador (si escribió algo)
|
||||||
|
$query = $request->input('search');
|
||||||
|
|
||||||
|
// Construimos la consulta
|
||||||
|
$products = Product::query()
|
||||||
|
->when($query, function ($q) use ($query) {
|
||||||
|
// Si hay búsqueda, filtra por nombre o SKU
|
||||||
|
return $q->where('name', 'like', "%{$query}%")
|
||||||
|
->orWhere('sku', 'like', "%{$query}%");
|
||||||
|
})
|
||||||
|
->orderBy('stock_quantity', 'asc') // Ordenamos primero los que tienen poco stock (Alerta visual)
|
||||||
|
->paginate(10) // Paginamos de a 10
|
||||||
|
->withQueryString(); // Mantiene el filtro de búsqueda al cambiar de página
|
||||||
|
|
||||||
return view('productos.index', compact('products'));
|
return view('productos.index', compact('products'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(){
|
/**
|
||||||
|
* Muestra el formulario de creación.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
return view('productos.create');
|
return view('productos.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id){
|
/**
|
||||||
$producto = Product::find($id);
|
* Guarda el producto nuevo en la base de datos.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// 1. Validamos los datos con las nuevas columnas
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'sku' => 'nullable|string|unique:products,sku|max:50', // SKU único
|
||||||
|
'description' => 'nullable|string',
|
||||||
|
'price' => 'required|numeric|min:0',
|
||||||
|
'cost' => 'nullable|numeric|min:0', // Costo opcional
|
||||||
|
'stock_quantity' => 'required|integer|min:0',
|
||||||
|
'min_stock_alert' => 'required|integer|min:0',
|
||||||
|
'type' => 'required|in:bike,accessory,service', // Solo permite estos 3 valores
|
||||||
|
'serial_number' => 'nullable|string|max:100',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 2. Si no viene SKU, generamos uno automático (Opcional pero útil)
|
||||||
|
if (empty($validated['sku'])) {
|
||||||
|
$validated['sku'] = 'GEN-' . strtoupper(uniqid());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Creamos el producto
|
||||||
|
Product::create($validated);
|
||||||
|
|
||||||
|
// 4. Redireccionamos con mensaje de éxito (Necesitas el componente Alert en el layout)
|
||||||
|
return redirect()->route('productos.index')
|
||||||
|
->with('success', 'Producto creado correctamente.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Muestra el detalle de un producto.
|
||||||
|
* Usamos Route Model Binding: Laravel busca el ID solo.
|
||||||
|
*/
|
||||||
|
public function show(Product $producto)
|
||||||
|
{
|
||||||
return view('productos.show', compact('producto'));
|
return view('productos.show', compact('producto'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id){
|
/**
|
||||||
$producto = Product::find($id);
|
* Muestra el formulario de edición.
|
||||||
|
*/
|
||||||
|
public function edit(Product $producto)
|
||||||
|
{
|
||||||
return view('productos.edit', compact('producto'));
|
return view('productos.edit', compact('producto'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request){
|
/**
|
||||||
$request->validate([
|
* Actualiza el producto existente.
|
||||||
'nombre' => 'required',
|
*/
|
||||||
'marca' => 'required',
|
public function update(Request $request, Product $producto)
|
||||||
'modelo' => 'required',
|
{
|
||||||
'descripcion' => 'required',
|
$validated = $request->validate([
|
||||||
'rodado' => 'required',
|
'name' => 'required|string|max:255',
|
||||||
'color' => 'required',
|
// Validamos que el SKU sea único PERO ignoramos el ID de este producto actual
|
||||||
'tipo' => 'required',
|
'sku' => ['nullable', 'string', Rule::unique('products')->ignore($producto->id)],
|
||||||
'precio' => 'required'
|
'description' => 'nullable|string',
|
||||||
|
'price' => 'required|numeric|min:0',
|
||||||
|
'cost' => 'nullable|numeric|min:0',
|
||||||
|
'stock_quantity' => 'required|integer|min:0',
|
||||||
|
'min_stock_alert' => 'required|integer|min:0',
|
||||||
|
'type' => 'required|in:bike,accessory,service',
|
||||||
|
'serial_number' => 'nullable|string|max:100',
|
||||||
]);
|
]);
|
||||||
Product::create($request->all());
|
|
||||||
|
|
||||||
return redirect(route('productos.index'));
|
$producto->update($validated);
|
||||||
|
|
||||||
|
return redirect()->route('productos.index')
|
||||||
|
->with('success', 'Producto actualizado exitosamente.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request,Product $producto){
|
/**
|
||||||
$request->validate([
|
* Elimina el producto.
|
||||||
'nombre' => 'required',
|
*/
|
||||||
'marca' => 'required',
|
public function destroy(Product $producto)
|
||||||
'modelo' => 'required',
|
{
|
||||||
'descripcion' => 'required',
|
|
||||||
'rodado' => 'required',
|
|
||||||
'color' => 'required',
|
|
||||||
'tipo' => 'required',
|
|
||||||
'precio' => 'required'
|
|
||||||
]);
|
|
||||||
$producto->update($request->all());
|
|
||||||
return redirect(route('productos.show',$producto));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id){
|
|
||||||
$producto = Product::find($id);
|
|
||||||
$producto->delete();
|
$producto->delete();
|
||||||
return redirect(route('productos.index'));
|
return redirect()->route('productos.index')
|
||||||
|
->with('success', 'Producto eliminado.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function vistaUsuario($id){
|
/**
|
||||||
$producto = Product::find($id);
|
* Vista simplificada para consultar precios (empleados).
|
||||||
return view('productos.vistaUsuario', compact('producto'));
|
*/
|
||||||
|
public function checker(Request $request)
|
||||||
|
{
|
||||||
|
$search = $request->input('query');
|
||||||
|
$result = null;
|
||||||
|
|
||||||
|
if ($search) {
|
||||||
|
$result = Product::where('sku', $search)
|
||||||
|
->orWhere('name', 'like', "%{$search}%")
|
||||||
|
->first(); // Devuelve el primer resultado encontrado
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('productos.checker', compact('result', 'search'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,28 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Appointment extends Model
|
class Appointment extends Model
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
use HasFactory;
|
||||||
// Así podrás hacer cosas como $turno->fecha_programada->format('d/m/Y')
|
|
||||||
protected $casts = [
|
protected $fillable = [
|
||||||
'fecha_programada' => 'datetime',
|
'client_id',
|
||||||
|
'scheduled_at',
|
||||||
|
'bike_model',
|
||||||
|
'problem_description',
|
||||||
|
'status',
|
||||||
|
'notes'
|
||||||
];
|
];
|
||||||
public function clients()
|
|
||||||
|
protected $casts = [
|
||||||
|
'scheduled_at' => 'datetime', // Laravel lo convierte a objeto Carbon automáticamente
|
||||||
|
];
|
||||||
|
|
||||||
|
// Relación: Un turno pertenece a un cliente
|
||||||
|
public function client()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Client::class);
|
return $this->belongsTo(Client::class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,25 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Client extends Model
|
class Client extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
protected $fillable = ['name', 'phone', 'email', 'address'];
|
||||||
|
|
||||||
// Un usuario (cliente) realiza muchas compras (ventas)
|
// Un usuario (cliente) realiza muchas compras (ventas)
|
||||||
public function sales()
|
public function sales()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Sale::class);
|
return $this->hasMany(Sale::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Relación: Un cliente tiene muchos turnos
|
||||||
|
public function appointments()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Appointment::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-9
@@ -8,16 +8,24 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
class Product extends Model
|
class Product extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'codigo',
|
'name',
|
||||||
'nombre',
|
'sku',
|
||||||
'costo',
|
'description',
|
||||||
'precio',
|
'price',
|
||||||
'stock',
|
'cost',
|
||||||
'min_stock',
|
'stock_quantity',
|
||||||
'categoria',
|
'min_stock_alert',
|
||||||
'descripcion'
|
'type',
|
||||||
|
'serial_number'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function hasLowStock(): bool
|
||||||
|
{
|
||||||
|
return $this->stock_quantity <= $this->min_stock_alert;
|
||||||
|
}
|
||||||
|
|
||||||
public function supplier()
|
public function supplier()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Suppliers::class);
|
return $this->belongsTo(Suppliers::class);
|
||||||
@@ -36,7 +44,6 @@ class Product extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(Sale::class, 'sale_details');
|
return $this->belongsToMany(Sale::class, 'sale_details');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**$user->sales: Te da la lista de todas las compras de ese usuario.
|
/**$user->sales: Te da la lista de todas las compras de ese usuario.
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,36 @@ class ProductFactory extends Factory
|
|||||||
*/
|
*/
|
||||||
public function definition(): array
|
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 [
|
return [
|
||||||
'nombre' => $this->faker->sentence(3),
|
'name' => $name,
|
||||||
'marca'=> $this->faker->randomElement(['Cube','Giant','Megamo','KTM','MMR','Liv','Ghost','Lapierre']),
|
'sku' => strtoupper($this->faker->bothify('???-#####')),
|
||||||
'modelo'=> $this->faker->bothify('????-####'),
|
'description' => $this->faker->sentence(10),
|
||||||
'rodado'=> $this->faker->numberBetween(12,30),
|
'price' => $price,
|
||||||
'color'=> $this->faker->safeColorName(),
|
'cost' => $cost,
|
||||||
'tipo'=> $this->faker->word(),
|
'stock_quantity' => $type === 'service' ? 0 : $this->faker->numberBetween(0, 50),
|
||||||
'descripcion'=> $this->faker->text(),
|
'min_stock_alert' => $this->faker->numberBetween(2, 10),
|
||||||
'precio'=> $this->faker->randomFloat(2,100,200)
|
'type' => $type,
|
||||||
|
// Nro de serie si es bicicleta
|
||||||
|
'serial_number' => $type === 'bike' ? strtoupper($this->faker->bothify('##??##??')) : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -13,14 +13,19 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('products', function (Blueprint $table) {
|
Schema::create('products', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('codigo')->unique();
|
$table->string('name');
|
||||||
$table->string('nombre');
|
$table->string('sku')->unique()->nullable(); // Código de barras o interno
|
||||||
$table->decimal('costo', 12, 2);
|
$table->text('description')->nullable();
|
||||||
$table->decimal('precio', 12, 2);
|
|
||||||
$table->integer('stock');
|
$table->decimal('price', 10, 2); // Precio venta
|
||||||
$table->integer('min_stock')->default(5);
|
$table->decimal('cost', 10, 2)->nullable(); // Costo (solo admin)
|
||||||
$table->string('categoria');
|
|
||||||
$table->text('descripcion');
|
$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->foreignId('suppliers_id')->constrained();
|
$table->foreignId('suppliers_id')->constrained();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,26 +2,71 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\Product;
|
|
||||||
use App\Models\User;
|
|
||||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
||||||
use Illuminate\Database\Seeder;
|
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
|
class DatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Seed the application's database.
|
|
||||||
*/
|
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::factory(10)->create();
|
//Crear el Super Admin
|
||||||
|
|
||||||
User::factory()->create([
|
User::factory()->create([
|
||||||
'name' => 'admin',
|
'name' => 'Jose Admin',
|
||||||
'email' => 'admin@laravel.com',
|
'email' => 'admin@lauck.com',
|
||||||
'password' => 'admin'
|
'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'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+165
@@ -0,0 +1,165 @@
|
|||||||
|
¡Perfecto\! Tus respuestas aclaran muchísimo el panorama. Al ser un sistema **Intranet (Local)** con un **Admin** y **Empleados** (visores/operadores), y con procesos manuales en el taller, podemos simplificar la arquitectura para lanzar un MVP (Producto Mínimo Viable) rápido y robusto, pero preparado para crecer.
|
||||||
|
|
||||||
|
Aquí tienes la **Guía Maestra de Desarrollo para Lauck Systems**.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
### 1\. Arquitectura de Base de Datos (El Cimiento)
|
||||||
|
|
||||||
|
Antes de escribir código, definamos las tablas. Laravel hace esto fácil con migraciones.
|
||||||
|
|
||||||
|
#### Tablas Principales:
|
||||||
|
|
||||||
|
1. **`users`** (Ya viene en Laravel)
|
||||||
|
|
||||||
|
* Agregamos campo: `role` (enum: 'admin', 'employee').
|
||||||
|
* *Lógica:* El Admin crea, edita y borra. El Empleado solo ve y registra ventas/turnos (según definas).
|
||||||
|
|
||||||
|
2. **`clients`** (Clientes)
|
||||||
|
|
||||||
|
* `name`, `phone` (clave para WhatsApp), `email`, `address`.
|
||||||
|
* *Nota:* Fundamental para agendar turnos y registrar garantías.
|
||||||
|
|
||||||
|
3. **`products`** (Inventario Mixto)
|
||||||
|
|
||||||
|
* `name`, `sku` (código único), `description`.
|
||||||
|
* `price` (precio venta), `cost` (costo, solo visible para admin).
|
||||||
|
* `stock_quantity` (entero).
|
||||||
|
* `min_stock_alert` (entero, para la alerta que pediste).
|
||||||
|
* `type` (enum: 'bike', 'accessory', 'service').
|
||||||
|
* `serial_number` (nullable, solo para bicicletas).
|
||||||
|
|
||||||
|
4. **`appointments`** (Turnos / Taller)
|
||||||
|
|
||||||
|
* `client_id` (relación).
|
||||||
|
* `scheduled_at` (datetime - fecha y hora del turno).
|
||||||
|
* `bike_model` (texto libre, ej: "Venzo Loki 29").
|
||||||
|
* `problem_description` (motivo de la consulta).
|
||||||
|
* `status` (enum: 'pending', 'confirmed', 'in\_progress', 'ready', 'delivered').
|
||||||
|
* `notes` (uso interno del mecánico).
|
||||||
|
|
||||||
|
5. **`sales`** (Ventas Internas / Historial)
|
||||||
|
|
||||||
|
* `user_id` (quién vendió).
|
||||||
|
* `client_id` (opcional, si es consumidor final anónimo).
|
||||||
|
* `total_amount`.
|
||||||
|
* `payment_method` (efectivo, tarjeta, transferencia).
|
||||||
|
* `created_at` (fecha de venta).
|
||||||
|
|
||||||
|
6. **`sale_items`** (Detalle de venta)
|
||||||
|
|
||||||
|
* `sale_id`, `product_id`, `quantity`, `unit_price`.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
### 2\. Estructura de Rutas y Controladores (Backend)
|
||||||
|
|
||||||
|
En Laravel, organizaremos esto por "Dominios".
|
||||||
|
|
||||||
|
* **Autenticación:** (Ya lo tienes con Breeze/Jetstream).
|
||||||
|
* **DashboardController:**
|
||||||
|
* `index()`: Muestra las tarjetas, alertas de stock bajo (query simple `Product::whereColumn('stock', '<=', 'min_stock')->get()`) y turnos de hoy.
|
||||||
|
* **ProductController:**
|
||||||
|
* CRUD completo (Crear, Leer, Actualizar, Borrar).
|
||||||
|
* Función extra `search()`: Para el buscador de precios de los empleados.
|
||||||
|
* **ClientController:**
|
||||||
|
* CRUD simple.
|
||||||
|
* **AppointmentController (Gestión de Taller):**
|
||||||
|
* `calendar()`: Vista de calendario o lista cronológica.
|
||||||
|
* `statusUpdate()`: Para mover el turno de "Pendiente" a "Listo".
|
||||||
|
* **SaleController:**
|
||||||
|
* `create()`: Formulario para registrar una salida de mercadería.
|
||||||
|
* `store()`: Resta el stock y guarda la venta.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
### 3\. Componentes de UI (Frontend - Blade + Tailwind)
|
||||||
|
|
||||||
|
Para mantener el estilo "Lauck" que ya definimos, necesitaremos crear estos componentes reutilizables (además de los que ya tienes):
|
||||||
|
|
||||||
|
1. **`x-ui.status-badge`**:
|
||||||
|
* Una etiqueta pequeña redondeada que cambia de color según el estado (Verde para 'Stock Alto', Rojo para 'Sin Stock' o 'Turno Atrasado', Amarillo para 'En Reparación').
|
||||||
|
2. **`x-ui.table`**:
|
||||||
|
* Una tabla estilizada con el modo oscuro, filas alternadas y cabeceras fijas. Vital para listas de precios y clientes.
|
||||||
|
3. **`x-forms.input` / `x-forms.select`**:
|
||||||
|
* Inputs con el estilo oscuro y borde neón al hacer foco, para no repetir las clases de Tailwind en cada formulario.
|
||||||
|
4. **`x-ui.alert`**:
|
||||||
|
* Para mostrar mensajes de éxito ("Producto guardado") o alertas ("¡Quedan solo 2 cámaras rodado 29\!").
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
### 4\. Funcionalidades Específicas a Implementar
|
||||||
|
|
||||||
|
Aquí está la lógica para los requerimientos que mencionaste:
|
||||||
|
|
||||||
|
#### A. Alertas de Stock ⚠️
|
||||||
|
|
||||||
|
* **Lógica:** No necesitas un sistema complejo de notificaciones en tiempo real todavía.
|
||||||
|
* **Implementación:** En el `DashboardController`, pasas una variable `$lowStockProducts` a la vista.
|
||||||
|
* **Vista:** En el Dashboard, si esa lista no está vacía, muestras una tarjeta roja o amarilla avisando "X productos con stock crítico".
|
||||||
|
|
||||||
|
#### B. Consulta de Precios (Modo Solo Lectura) 🔍
|
||||||
|
|
||||||
|
* **Requerimiento:** Empleados consultan, no editan.
|
||||||
|
* **Implementación:**
|
||||||
|
* Crear una vista `products.checker`.
|
||||||
|
* Un input de búsqueda grande en el centro.
|
||||||
|
* Al escribir (AJAX o Livewire sería ideal aquí, pero un form simple con botón "Buscar" funciona), muestra una tarjeta gigante con el Nombre y el Precio.
|
||||||
|
* *Seguridad:* Usar **Laravel Gates** o **Policies**.
|
||||||
|
```php
|
||||||
|
// En AuthServiceProvider
|
||||||
|
Gate::define('edit-products', function ($user) {
|
||||||
|
return $user->role === 'admin';
|
||||||
|
});
|
||||||
|
```
|
||||||
|
En Blade: `@can('edit-products') <button>Editar</button> @endcan`. Así el empleado ve el producto pero no el botón de editar.
|
||||||
|
|
||||||
|
#### C. Agenda de Turnos 📅
|
||||||
|
|
||||||
|
* **Lógica:** "Consulta -\> Cita".
|
||||||
|
* **Implementación:**
|
||||||
|
* No te compliques con un calendario visual complejo (tipo Google Calendar) al principio.
|
||||||
|
* Usa una **Lista Agrupada por Días**.
|
||||||
|
* *Ejemplo visual:*
|
||||||
|
* **HOY:**
|
||||||
|
* 09:00 - Jose (Pincharura) [Ver]
|
||||||
|
* 10:30 - Maria (Service General) [Ver]
|
||||||
|
* **MAÑANA:**
|
||||||
|
* ...
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
### 5\. Roadmap Sugerido (Paso a Paso)
|
||||||
|
|
||||||
|
Este es el orden lógico para programar sin perderse:
|
||||||
|
|
||||||
|
1. **Semana 1: Cimientos y Stock (Lo más urgente)**
|
||||||
|
|
||||||
|
* Configurar Migraciones (`products`, `clients`).
|
||||||
|
* Crear Modelos y Seeders (datos falsos para probar).
|
||||||
|
* Hacer el CRUD de Productos (Alta, Baja y Modificación).
|
||||||
|
* *Hito:* Poder cargar una bicicleta y verla en la lista.
|
||||||
|
|
||||||
|
2. **Semana 2: Seguridad y Consultas**
|
||||||
|
|
||||||
|
* Agregar campo `role` a Users.
|
||||||
|
* Crear la vista "Consulta de Precios" (solo lectura).
|
||||||
|
* Proteger las rutas de edición para que solo el Admin entre.
|
||||||
|
* *Hito:* El empleado puede loguearse y buscar un precio, pero no borrar nada.
|
||||||
|
|
||||||
|
3. **Semana 3: El Taller (Turnos)**
|
||||||
|
|
||||||
|
* Crear migración `appointments`.
|
||||||
|
* Crear formulario para "Nuevo Turno" (Seleccionar Cliente + Fecha + Motivo).
|
||||||
|
* Crear vista de "Lista de Turnos" en el Dashboard.
|
||||||
|
* *Hito:* Dejar de usar el cuaderno de papel para los turnos.
|
||||||
|
|
||||||
|
4. **Semana 4: Refinamiento**
|
||||||
|
|
||||||
|
* Alertas de stock visuales.
|
||||||
|
* Mejoras estéticas (Dark Mode en tablas).
|
||||||
|
* Pruebas finales en el servidor local.
|
||||||
|
|
||||||
|
### ¿Cómo seguimos?
|
||||||
|
|
||||||
|
¿Te gustaría que generemos el código para la **Migración de Productos** y el **Modelo**, o prefieres que diseñemos primero el componente visual de la **Tabla de Stock**?
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
@props(['type' => 'dark'])
|
|
||||||
|
|
||||||
@php
|
|
||||||
switch ($type) {
|
|
||||||
case 'info':
|
|
||||||
$class = 'text-blue-800 bg-blue-50 dark:text-blue-400';
|
|
||||||
break;
|
|
||||||
case 'danger':
|
|
||||||
$class = 'text-red-800 bg-red-50 dark:text-red-400';
|
|
||||||
break;
|
|
||||||
case 'success':
|
|
||||||
$class = 'text-green-800 bg-green-50 dark:text-green-400';
|
|
||||||
break;
|
|
||||||
case 'warning':
|
|
||||||
$class = 'text-yellow-800 bg-yellow-50 dark:text-yellow-300';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$class = 'text-gray-800 bg-gray-50 dark:text-gray-300';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
<div {{$attributes->merge(['class'=>'p-4 my-4 mx-auto text-md max-w-[80%] rounded-lg dark:bg-gray-800 '.$class])}} role="alert">
|
|
||||||
<span class="font-semibold">{{$title}}</span> {{$content}}
|
|
||||||
</div>
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
@props(['disabled' => false, 'error' => null])
|
||||||
|
|
||||||
|
<input {{ $disabled ? 'disabled' : ''}} {!! $attributes->merge(['class' => 'bg-neutral-800 border-neutral-700 text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5 placeholder-gray-500 transition-colors ' . ($error ? 'border-red-500 focus:border-red-500 focus:ring-red-500' : '')]) !!}>
|
||||||
|
|
||||||
|
@if($error)
|
||||||
|
<p class="mt-1 text-xs text-red-400">{{ $error }}</p>
|
||||||
|
@endif
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@props(['value'])
|
||||||
|
|
||||||
|
<label {!! $attributes->merge(['class' => 'block mb-2 text-xs font-bold text-gray-400 uppercase tracking-wider']) !!}>
|
||||||
|
{{$value ?? $slot}}
|
||||||
|
</label>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
@props(['disabled' => false, 'error' => null, 'options' => [], 'placeholder' => 'Seleccionar...'])
|
||||||
|
|
||||||
|
<!-- Contenedor relativo para posicionar la flecha personalizada si quisiéramos (opcional) -->
|
||||||
|
<div class="relative">
|
||||||
|
<select {{ $disabled ? 'disabled' : '' }} {!! $attributes->merge(['class' => '
|
||||||
|
appearance-none bg-transparent border-0 border-b-2 border-neutral-700 text-white text-sm
|
||||||
|
py-2.5 px-0 w-full focus:outline-none focus:ring-0 focus:border-neon-lime peer cursor-pointer
|
||||||
|
transition-colors' . ($error ? 'border-red-500 focus:border-red-500' : '')
|
||||||
|
]) !!}>
|
||||||
|
|
||||||
|
@if($placeholder)
|
||||||
|
<option value="" disabled selected class="bg-neutral-800 text-gray-500">{{ $placeholder }}</option>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{ $slot }}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- Flecha personalizada (SVG) posicionada a la derecha -->
|
||||||
|
<div class="absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none">
|
||||||
|
<svg class="w-4 h-4 text-gray-500 peer-focus:text-neon-lime transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mensaje de error -->
|
||||||
|
@if($error)
|
||||||
|
<p class="mt-1 text-xs text-red-400">{{ $error }}</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{--
|
||||||
|
NOTA DE ESTILO:
|
||||||
|
- `appearance-none`: Quita el estilo feo por defecto del navegador.
|
||||||
|
- `bg-transparent`: Fondo transparente para que se vea el color de fondo de tu web.
|
||||||
|
- `border-b-2`: Borde solo abajo (estilo línea).
|
||||||
|
- `focus:ring-0`: Quita el anillo azul de Chrome al hacer click.
|
||||||
|
- `peer`: Permite que el icono de la flecha cambie de color cuando el select tiene foco.
|
||||||
|
--}}
|
||||||
@@ -36,7 +36,10 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="block py-2 px-3 text-white hover:text-neon-lime md:hover:bg-transparent md:border-0 md:p-0 transition-colors">Taller</a>
|
<a href="#"
|
||||||
|
class="block py-2 px-3 md:p-0 transition-colors {{ request()->is('mantenimiento*') ? 'text-neon-lime border-b-2 border-neon-lime' : 'text-white hover:text-neon-lime' }}">
|
||||||
|
Taller
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('sales.create') }}"
|
<a href="{{ route('sales.create') }}"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<h1 class="font-black text-4xl md:text-5xl text-white uppercase italic">
|
<h1 class="font-black text-4xl md:text-5xl text-white uppercase italic">
|
||||||
{{ $title }}
|
{{ $title }}
|
||||||
@if($highlight)
|
@if($highlight)
|
||||||
<span class="text-transparent bg-clip-text bg-gradient-to-r from-white to-gray-500">{{ $highlight }}</span>
|
<span class="text-transparent bg-clip-text bg-gradient-to-r from-white to-gray-500 pe-2">{{ $highlight }}</span>
|
||||||
@endif
|
@endif
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@if (session('success'))
|
||||||
|
<div class="p-4 mb-4 text-sm text-green-400 rounded-lg bg-neutral-800 border border-green-800/50" role="alert">
|
||||||
|
<span class="font-bold">¡Éxito!</span> {{ session('success') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="p-4 mb-4 text-sm text-red-400 rounded-lg bg-neutral-800 border border-red-800/50" role="alert">
|
||||||
|
<span class="font-bold">Error:</span> {{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
@props(['color' => 'gray'])
|
||||||
|
|
||||||
|
@php
|
||||||
|
$colors = [
|
||||||
|
'gray' => 'bg-gray-700 text-gray-300',
|
||||||
|
'red' => 'bg-red-900/50 text-red-300 border border-red-800',
|
||||||
|
'green' => 'bg-green-900/50 text-green-300 border border-green-800',
|
||||||
|
'yellow' => 'bg-yellow-900/50 text-yellow-300 border border-yellow-800',
|
||||||
|
'neon' => 'bg-[#ccff00]/10 text-[#ccff00] border border-[#ccff00]/50',
|
||||||
|
];
|
||||||
|
$classes = $colors[$color] ?? $colors['gray'];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<span class="{{ $classes }} text-xs font-medium me-2 px-2.5 py-0.5 rounded border">
|
||||||
|
{{ $slot }}
|
||||||
|
</span>
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
||||||
<title>@yield('title','Lauck - Home')</title>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>Cabeza</header>
|
|
||||||
|
|
||||||
@yield('main')
|
|
||||||
|
|
||||||
<footer>Pies</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,16 +1,11 @@
|
|||||||
<x-appc>
|
{{-- <x-layout title="Lauck - Agregar">
|
||||||
<x-slot name="title">Lauck - Agregar</x-slot>
|
|
||||||
<x-slot name="navTitle">Agregar - Producto</x-slot>
|
|
||||||
|
|
||||||
@if ($errors->any())
|
|
||||||
<x-alert type="danger">
|
|
||||||
<x-slot name="title">Error: </x-slot>
|
|
||||||
<x-slot name="content">Todos los campos son obligatorios.</x-slot>
|
|
||||||
</x-alert>
|
|
||||||
@endif
|
|
||||||
<div class="w-full h-fit flex flex-col justify-start items-center gap-3 p-18">
|
<div class="w-full h-fit flex flex-col justify-start items-center gap-3 p-18">
|
||||||
<form class="w-lg mx-auto" action="{{route('productos.store')}}" method="POST">
|
<form class="w-lg mx-auto" action="{{route('productos.store')}}" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
|
<x-forms.input></x-forms>
|
||||||
|
|
||||||
<div class="relative z-0 w-full mb-5 group">
|
<div class="relative z-0 w-full mb-5 group">
|
||||||
<input type="text" value="{{old('nombre')}}" name="nombre" id="nombre" class="block py-2.5 px-0 w-full text-sm text-gray-300 bg-transparent border-0 border-b-2 border-gray-300 appearance-none dark:text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" "/>
|
<input type="text" value="{{old('nombre')}}" name="nombre" id="nombre" class="block py-2.5 px-0 w-full text-sm text-gray-300 bg-transparent border-0 border-b-2 border-gray-300 appearance-none dark:text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" "/>
|
||||||
<label for="nombre" class="peer-focus:font-medium absolute text-sm text-gray-300 dark:text-gray-300 duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:start-0 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Titulo</label>
|
<label for="nombre" class="peer-focus:font-medium absolute text-sm text-gray-300 dark:text-gray-300 duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:start-0 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Titulo</label>
|
||||||
@@ -58,4 +53,79 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</x-appc>
|
</x-layout> --}}
|
||||||
|
|
||||||
|
<x-layout title="Nuevo Producto">
|
||||||
|
|
||||||
|
<x-section-header subtitle="Inventario" title="Nuevo " highlight="Producto" />
|
||||||
|
|
||||||
|
<div class="w-full max-w-4xl mx-auto bg-panel-bg border border-neutral-800 rounded-xl p-8 shadow-lg">
|
||||||
|
|
||||||
|
<form action="{{ route('productos.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<!-- Grid Layout -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
||||||
|
|
||||||
|
<!-- Nombre (Ocupa 2 columnas) -->
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<x-forms.label for="name" value="Nombre del Producto" />
|
||||||
|
<x-forms.input id="name" name="name" type="text" :value="old('name')" required autofocus placeholder="Ej: Cámara 29 Válvula Auto" :error="$errors->first('name')" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- SKU -->
|
||||||
|
<div>
|
||||||
|
<x-forms.label for="sku" value="Código SKU (Opcional)" />
|
||||||
|
<x-forms.input id="sku" name="sku" type="text" :value="old('sku')" placeholder="Dejar vacío para generar auto" :error="$errors->first('sku')" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tipo -->
|
||||||
|
<div>
|
||||||
|
<x-forms.label for="type" value="Tipo de Producto" />
|
||||||
|
<select id="type" name="type" class="bg-neutral-800 border-neutral-700 text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5">
|
||||||
|
<option value="accessory" {{ old('type') == 'accessory' ? 'selected' : '' }}>Accesorio / Repuesto</option>
|
||||||
|
<option value="bike" {{ old('type') == 'bike' ? 'selected' : '' }}>Bicicleta</option>
|
||||||
|
<option value="service" {{ old('type') == 'service' ? 'selected' : '' }}>Servicio / Mano de Obra</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Precios -->
|
||||||
|
<div>
|
||||||
|
<x-forms.label for="price" value="Precio Venta ($)" />
|
||||||
|
<x-forms.input id="price" name="price" type="number" step="0.01" :value="old('price')" required :error="$errors->first('price')" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<x-forms.label for="cost" value="Costo ($) - Solo Admin" />
|
||||||
|
<x-forms.input id="cost" name="cost" type="number" step="0.01" :value="old('cost')" :error="$errors->first('cost')" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Stock -->
|
||||||
|
<div>
|
||||||
|
<x-forms.label for="stock_quantity" value="Cantidad Inicial" />
|
||||||
|
<x-forms.input id="stock_quantity" name="stock_quantity" type="number" :value="old('stock_quantity', 0)" required :error="$errors->first('stock_quantity')" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<x-forms.label for="min_stock_alert" value="Alerta de Stock Mínimo" />
|
||||||
|
<x-forms.input id="min_stock_alert" name="min_stock_alert" type="number" :value="old('min_stock_alert', 5)" required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Descripción (2 columnas) -->
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<x-forms.label for="description" value="Descripción / Notas" />
|
||||||
|
<textarea id="description" name="description" rows="3" class="bg-neutral-800 border-neutral-700 text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5 placeholder-gray-500">{{ old('description') }}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botones Acción -->
|
||||||
|
<div class="flex items-center justify-end space-x-4 border-t border-neutral-800 pt-6">
|
||||||
|
<a href="{{ route('productos.index') }}" class="text-gray-400 hover:text-white font-medium text-sm transition-colors">Cancelar</a>
|
||||||
|
<button type="submit" class="px-6 py-2.5 bg-neon-lime text-neutral-900 font-bold rounded-lg hover:bg-[#b3e600] transition-colors shadow-lg shadow-neon-lime/20">
|
||||||
|
Guardar Producto
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</x-layout>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<x-appc>
|
{{-- <x-appc>
|
||||||
<x-slot name="title">Lauck - Home - Productos</x-slot>
|
<x-slot name="title">Lauck - Home - Productos</x-slot>
|
||||||
<x-slot name="navTitle">Productos</x-slot>
|
<x-slot name="navTitle">Productos</x-slot>
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<tr class="bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200">
|
<tr class="bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200">
|
||||||
<th scope="row"
|
<th scope="row"
|
||||||
class="px-6 py-4 font-medium text-neutral-900 whitespace-nowrap dark:text-white">
|
class="px-6 py-4 font-medium text-neutral-900 whitespace-nowrap dark:text-white">
|
||||||
<a href="{{route('productos.show',$prod)}}">{{ $prod->nombre }}</a>
|
<a href="{{route('productos.show',$prod)}}">{{ $prod->name }}</a>
|
||||||
</th>
|
</th>
|
||||||
<td class="px-6 py-4">{{ $prod->marca }}</td>
|
<td class="px-6 py-4">{{ $prod->marca }}</td>
|
||||||
<td class="px-6 py-4">{{ $prod->modelo }}</td>
|
<td class="px-6 py-4">{{ $prod->modelo }}</td>
|
||||||
@@ -41,4 +41,92 @@
|
|||||||
{{$products->links()}}
|
{{$products->links()}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</x-appc>
|
</x-appc> --}}
|
||||||
|
|
||||||
|
<x-layout title="Stock - Lauck">
|
||||||
|
|
||||||
|
<x-section-header subtitle="Gestión de Inventario" title="Listado de " highlight="Productos" />
|
||||||
|
|
||||||
|
<!-- Mensajes de feedback -->
|
||||||
|
<x-ui.alert />
|
||||||
|
|
||||||
|
<!-- Barra de Herramientas (Buscador + Botón Crear) -->
|
||||||
|
<div class="w-full flex flex-col md:flex-row justify-between items-center gap-4 mb-6">
|
||||||
|
|
||||||
|
<!-- Buscador -->
|
||||||
|
<form action="{{ route('productos.index') }}" method="GET" class="w-full md:w-1/2">
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
|
||||||
|
<svg class="w-4 h-4 text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<input type="text" name="search" value="{{ request('search') }}"
|
||||||
|
class="block w-full p-3 ps-10 text-sm text-white border border-neutral-700 rounded-lg bg-neutral-800 focus:ring-neon-lime focus:border-neon-lime placeholder-gray-500"
|
||||||
|
placeholder="Buscar por nombre, SKU o marca...">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Botón Nuevo -->
|
||||||
|
<a href="{{ route('productos.create') }}" class="w-full md:w-auto text-center px-5 py-3 text-sm font-bold text-neutral-900 bg-neon-lime rounded-lg hover:bg-[#b3e600] transition-colors uppercase tracking-wide">
|
||||||
|
+ Nuevo Producto
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tabla de Productos -->
|
||||||
|
<div class="relative overflow-x-auto shadow-md sm:rounded-lg border border-neutral-800 w-full">
|
||||||
|
<table class="w-full text-sm text-left rtl:text-right text-gray-400">
|
||||||
|
<thead class="text-xs text-gray-300 uppercase bg-neutral-800 border-b border-neutral-700">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3">Producto / SKU</th>
|
||||||
|
<th scope="col" class="px-6 py-3">Tipo</th>
|
||||||
|
<th scope="col" class="px-6 py-3">Precio</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-center">Stock</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-right">Acciones</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($products as $product)
|
||||||
|
<tr class="bg-neutral-900/50 border-b border-neutral-800 hover:bg-neutral-800 transition-colors group">
|
||||||
|
<td class="px-6 py-4 font-medium text-white whitespace-nowrap">
|
||||||
|
<div class="text-base font-bold">{{ $product->name }}</div>
|
||||||
|
<div class="text-xs text-gray-500 font-mono">{{ $product->sku }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4">
|
||||||
|
@if($product->type === 'bike') <x-ui.badge color="neon">Bicicleta</x-ui.badge>
|
||||||
|
@elseif($product->type === 'accessory') <x-ui.badge color="gray">Accesorio</x-ui.badge>
|
||||||
|
@else <x-ui.badge color="yellow">Servicio</x-ui.badge> @endif
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 font-mono text-white">
|
||||||
|
${{ number_format($product->price, 2) }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 text-center">
|
||||||
|
@if($product->type === 'service')
|
||||||
|
<span class="text-gray-600">-</span>
|
||||||
|
@elseif($product->stock_quantity <= $product->min_stock_alert)
|
||||||
|
<x-ui.badge color="red">{{ $product->stock_quantity }}</x-ui.badge>
|
||||||
|
@else
|
||||||
|
<x-ui.badge color="green">{{ $product->stock_quantity }}</x-ui.badge>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 text-right">
|
||||||
|
<a href="{{ route('productos.edit', $product) }}" class="font-medium text-blue-400 hover:underline mr-3">Editar</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="px-6 py-10 text-center text-gray-500">
|
||||||
|
No se encontraron productos.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Paginación -->
|
||||||
|
<div class="mt-4 w-full">
|
||||||
|
{{ $products->links() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</x-layout>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<x-appc>
|
<x-layout title="Productos - Lauck">
|
||||||
<x-slot name="title">Lauck - Vista - Producto</x-slot>
|
|
||||||
<x-slot name="navTitle">Producto - {{$producto->nombre}}</x-slot>
|
<!-- Header -->
|
||||||
|
<x-section-header subtitle="Panel de Control" title="¡Bienvenido, " highlight="Jose!"/>
|
||||||
|
|
||||||
<div class="w-full min-h-7/12 mx-auto px-4 my-5 flex flex-col gap-5 items-center justify-center">
|
<div class="w-full min-h-7/12 mx-auto px-4 my-5 flex flex-col gap-5 items-center justify-center">
|
||||||
<dl class="w-lg text-gray-900 dark:text-white *:border-b *:border-gray-200 *:dark:border-gray-400">
|
<dl class="w-lg text-gray-900 dark:text-white *:border-b *:border-gray-200 *:dark:border-gray-400">
|
||||||
@@ -46,8 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</x-layout>
|
||||||
</x-appc>
|
|
||||||
|
|
||||||
{{-- componente alerta --}}
|
{{-- componente alerta --}}
|
||||||
{{-- <x-alert type="success">
|
{{-- <x-alert type="success">
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<x-layout title="Nuevo Producto">
|
||||||
|
|
||||||
|
<x-section-header subtitle="Ventas" title="Registro de " :highlight="'ventas ' . ' '" />
|
||||||
|
<!-- Mensajes de feedback -->
|
||||||
|
<x-ui.alert />
|
||||||
|
|
||||||
|
<!-- Barra de Herramientas (Buscador + Botón Crear) -->
|
||||||
|
<div class="w-full flex flex-col md:flex-row justify-between items-center gap-4 mb-6">
|
||||||
|
|
||||||
|
<!-- Buscador -->
|
||||||
|
<form action="{{ url('sales') }}" method="GET" class="flex flex-row w-full max-w-3xl gap-4">
|
||||||
|
<div class="relative w-2/3">
|
||||||
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
|
||||||
|
<svg class="w-4 h-4 text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<input type="text" name="search" value="{{ request('search') }}"
|
||||||
|
class="block w-full p-3 ps-10 text-sm text-white border border-neutral-700 rounded-lg bg-neutral-800 focus:ring-neon-lime focus:border-neon-lime placeholder-gray-500"
|
||||||
|
placeholder="Buscar por nombre, SKU o marca...">
|
||||||
|
</div>
|
||||||
|
<div class="w-1/3">
|
||||||
|
<x-forms.select id="type" name="type" :error="$errors->first('type')" placeholder="Filtro...">
|
||||||
|
<option value="bike" class="bg-neutral-800">Bicicleta</option>
|
||||||
|
<option value="accessory" class="bg-neutral-800">Accesorio</option>
|
||||||
|
<option value="service" class="bg-neutral-800">Servicio</option>
|
||||||
|
</x-forms.select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Botón Nuevo -->
|
||||||
|
<a href="{{ route('productos.create') }}" class="w-full md:w-auto text-center px-5 py-3 text-sm font-bold text-neutral-900 bg-neon-lime rounded-lg hover:bg-[#b3e600] transition-colors uppercase tracking-wide">
|
||||||
|
+ Registrar Venta
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tabla de Productos -->
|
||||||
|
<div class="relative overflow-x-auto shadow-md sm:rounded-lg border border-neutral-800 w-full">
|
||||||
|
<table class="w-full text-sm text-left rtl:text-right text-gray-400">
|
||||||
|
<thead class="text-xs text-gray-300 uppercase bg-neutral-800 border-b border-neutral-700">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3">ID Venta</th>
|
||||||
|
<th scope="col" class="px-6 py-3">Descripcion</th>
|
||||||
|
<th scope="col" class="px-6 py-3">Cant. Productos</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-center">Total Venta</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-right">Acciones</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($sales as $product)
|
||||||
|
<tr class="bg-neutral-900/50 border-b border-neutral-800 hover:bg-neutral-800 transition-colors group">
|
||||||
|
<td class="px-6 py-4 font-medium text-white whitespace-nowrap">
|
||||||
|
<div class="text-gray-500 font-mono">{{ $product->sku }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 font-medium text-white whitespace-nowrap">
|
||||||
|
<div class="text-base font-bold">{{ $product->name }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 font-mono text-white">
|
||||||
|
{{ $product->stock_quantity }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 font-mono text-white text-center">
|
||||||
|
${{ number_format(($product->price * 2), 2) }}
|
||||||
|
{{-- @if($product->type === 'service')
|
||||||
|
<span class="text-gray-600">-</span>
|
||||||
|
@elseif($product->stock_quantity <= $product->min_stock_alert)
|
||||||
|
<x-ui.badge color="red">{{ $product->stock_quantity }}</x-ui.badge>
|
||||||
|
@else
|
||||||
|
<x-ui.badge color="green">{{ $product->stock_quantity }}</x-ui.badge>
|
||||||
|
@endif --}}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 text-right">
|
||||||
|
<a href="{{ route('productos.edit', $product) }}" class="font-medium text-blue-400 hover:underline mr-3">Editar</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="px-6 py-10 text-center text-gray-500">
|
||||||
|
No se encontraron productos.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Paginación -->
|
||||||
|
<div class="mt-4 w-full">
|
||||||
|
{{ $sales->links() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</x-layout>
|
||||||
+4
-5
@@ -39,13 +39,11 @@ Route::view('register', 'register')->name('register');
|
|||||||
Route::post('register', RegisterController::class)->name('register.store');
|
Route::post('register', RegisterController::class)->name('register.store');
|
||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/productos',[ProductosController::class,'index'])->name('productos.index');
|
Route::resource('productos', ProductosController::class)->parameters([
|
||||||
Route::get('/productos/create',[ProductosController::class,'create'])->name('productos.create');
|
'productos' => 'producto'
|
||||||
|
]);
|
||||||
Route::get('/productos/{id}', [ProductosController::class,'show'])->name('productos.show');
|
Route::get('/productos/{id}', [ProductosController::class,'show'])->name('productos.show');
|
||||||
Route::get('/productos/{id}/edit', [ProductosController::class,'edit'])->name('productos.edit');
|
Route::get('/productos/{id}/edit', [ProductosController::class,'edit'])->name('productos.edit');
|
||||||
Route::post('/productos',[ProductosController::class,'store'])->name('productos.store');
|
|
||||||
Route::put('/productos/{id}',[ProductosController::class,'update'])->name('productos.update');
|
|
||||||
Route::delete('/productos/{id}', [ProductosController::class,'destroy'])->name('productos.destroy');
|
|
||||||
|
|
||||||
// mostrar
|
// mostrar
|
||||||
Route::get('/sales/create', [SaleController::class, 'create'])->name('sales.create');
|
Route::get('/sales/create', [SaleController::class, 'create'])->name('sales.create');
|
||||||
@@ -53,6 +51,7 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
Route::post('/sales', [SaleController::class, 'store'])->name('sales.store');
|
Route::post('/sales', [SaleController::class, 'store'])->name('sales.store');
|
||||||
// Route::get('/sales', [SaleController::class, 'index'])->name('sales.index');
|
// Route::get('/sales', [SaleController::class, 'index'])->name('sales.index');
|
||||||
// Route::get('/sales/create', [SaleController::class, 'create'])->name('sales.create');
|
// Route::get('/sales/create', [SaleController::class, 'create'])->name('sales.create');
|
||||||
|
Route::get('/checker', [ProductosController::class, 'checker'])->name('productos.checker');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/catalogo', [CatalogoController::class,'catalogo'])->name('catalogo');
|
Route::get('/catalogo', [CatalogoController::class,'catalogo'])->name('catalogo');
|
||||||
|
|||||||
Reference in New Issue
Block a user