Implementación de controladores y modelos
This commit is contained in:
parent
49e5adc249
commit
f47a551d46
18
app/Http/Controllers/CategoryController.php
Normal file
18
app/Http/Controllers/CategoryController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
18
app/Http/Controllers/InventoryController.php
Normal file
18
app/Http/Controllers/InventoryController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class InventoryController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
18
app/Http/Controllers/PriceController.php
Normal file
18
app/Http/Controllers/PriceController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class PriceController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
18
app/Http/Controllers/SaleController.php
Normal file
18
app/Http/Controllers/SaleController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class SaleController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
18
app/Http/Controllers/SaleDetailController.php
Normal file
18
app/Http/Controllers/SaleDetailController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class SaleDetailController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
27
app/Models/Category.php
Normal file
27
app/Models/Category.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php namespace App\Models;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class Category extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
29
app/Models/Inventory.php
Normal file
29
app/Models/Inventory.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php namespace App\Models;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class Inventory extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'category_id',
|
||||||
|
'name',
|
||||||
|
'sku',
|
||||||
|
'stock',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
30
app/Models/Price.php
Normal file
30
app/Models/Price.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php namespace App\Models;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class Price extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'inventory_id',
|
||||||
|
'cost',
|
||||||
|
'retail_price',
|
||||||
|
'tax',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'cost' => 'decimal:2',
|
||||||
|
'retail_price' => 'decimal:2',
|
||||||
|
'tax' => 'decimal:2',
|
||||||
|
];
|
||||||
|
}
|
||||||
33
app/Models/Sale.php
Normal file
33
app/Models/Sale.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php namespace App\Models;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class Sale extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'invoice_number',
|
||||||
|
'subtotal',
|
||||||
|
'tax',
|
||||||
|
'total',
|
||||||
|
'payment_method',
|
||||||
|
'status',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'subtotal' => 'decimal:2',
|
||||||
|
'tax' => 'decimal:2',
|
||||||
|
'total' => 'decimal:2',
|
||||||
|
];
|
||||||
|
}
|
||||||
31
app/Models/SaleDetail.php
Normal file
31
app/Models/SaleDetail.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php namespace App\Models;
|
||||||
|
/**
|
||||||
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descripción
|
||||||
|
*
|
||||||
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
class SaleDetail extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'sale_id',
|
||||||
|
'inventory_id',
|
||||||
|
'product_name',
|
||||||
|
'quantity',
|
||||||
|
'unit_price',
|
||||||
|
'subtotal',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'unit_price' => 'decimal:2',
|
||||||
|
'subtotal' => 'decimal:2',
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -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('categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('categories');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
<?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('inventories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('sku')->unique();
|
||||||
|
$table->integer('stock')->default(0);
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('inventories');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -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('prices', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('inventory_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->decimal('cost', 10, 2);
|
||||||
|
$table->decimal('retail_price', 10, 2);
|
||||||
|
$table->decimal('tax', 5, 2);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('prices');
|
||||||
|
}
|
||||||
|
};
|
||||||
35
database/migrations/2025_12_30_151443_create_sales_table.php
Normal file
35
database/migrations/2025_12_30_151443_create_sales_table.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?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('sales', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('invoice_number')->unique();
|
||||||
|
$table->decimal('subtotal', 10, 2);
|
||||||
|
$table->decimal('tax', 10, 2);
|
||||||
|
$table->decimal('total', 10, 2);
|
||||||
|
$table->enum('payment_method', ['cash', 'credit_card', 'debit_card']);
|
||||||
|
$table->enum('status', ['pending', 'completed', 'cancelled'])->default('pending');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sales');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
<?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('sale_details', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('sale_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('inventory_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('product_name');
|
||||||
|
$table->integer('quantity');
|
||||||
|
$table->decimal('unit_price', 10, 2);
|
||||||
|
$table->decimal('subtotal', 10, 2);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sale_details');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -3,16 +3,20 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: dockerfile
|
dockerfile: dockerfile
|
||||||
|
args:
|
||||||
|
USER_ID: 1000
|
||||||
|
GROUP_ID: 1000
|
||||||
working_dir: /var/www/pdv.backend
|
working_dir: /var/www/pdv.backend
|
||||||
|
user: "1000:1000"
|
||||||
environment:
|
environment:
|
||||||
- DB_HOST=mysql
|
- DB_HOST=mysql
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
- DB_PASSWORD=${DB_PASSWORD}
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
- DB_DATABASE=${DB_DATABASE}
|
- DB_DATABASE=${DB_DATABASE}
|
||||||
- DB_PORT=${DB_PORT}
|
- DB_PORT=${DB_PORT}
|
||||||
|
- HOME=/tmp
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/var/www/pdv.backend
|
- ./:/var/www/pdv.backend
|
||||||
- /var/www/pdv.backend/vendor
|
|
||||||
networks:
|
networks:
|
||||||
- pdv-network
|
- pdv-network
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@ -34,6 +34,11 @@ RUN mkdir -p storage/app/keys storage/logs bootstrap/cache
|
|||||||
RUN chown -R www-data:www-data /var/www/pdv.backend/storage /var/www/pdv.backend/bootstrap/cache
|
RUN chown -R www-data:www-data /var/www/pdv.backend/storage /var/www/pdv.backend/bootstrap/cache
|
||||||
RUN chmod -R 775 /var/www/pdv.backend/storage /var/www/pdv.backend/bootstrap/cache
|
RUN chmod -R 775 /var/www/pdv.backend/storage /var/www/pdv.backend/bootstrap/cache
|
||||||
|
|
||||||
|
# Configurar usuario para evitar problemas de permisos
|
||||||
|
ARG USER_ID=1000
|
||||||
|
ARG GROUP_ID=1000
|
||||||
|
RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Configurar Git sin necesidad de permisos globales
|
||||||
|
export GIT_CONFIG_GLOBAL=/tmp/.gitconfig
|
||||||
git config --global --add safe.directory /var/www/pdv.backend
|
git config --global --add safe.directory /var/www/pdv.backend
|
||||||
|
|
||||||
echo "=== Iniciando entrypoint DESARROLLO ==="
|
echo "=== Iniciando entrypoint DESARROLLO ==="
|
||||||
|
|
||||||
chown -R www-data:www-data /var/www/pdv.backend/storage /var/www/pdv.backend/bootstrap/cache
|
|
||||||
chmod -R 775 /var/www/pdv.backend/storage /var/www/pdv.backend/bootstrap/cache
|
|
||||||
|
|
||||||
# Variables desde Docker environment
|
# Variables desde Docker environment
|
||||||
DB_HOST=${DB_HOST:-mysql}
|
DB_HOST=${DB_HOST:-mysql}
|
||||||
DB_USERNAME=${DB_USERNAME:-root}
|
DB_USERNAME=${DB_USERNAME:-root}
|
||||||
@ -82,7 +81,6 @@ fi
|
|||||||
# Establecer permisos correctos para las claves
|
# Establecer permisos correctos para las claves
|
||||||
chmod 600 storage/app/keys/oauth-private.key
|
chmod 600 storage/app/keys/oauth-private.key
|
||||||
chmod 644 storage/app/keys/oauth-public.key
|
chmod 644 storage/app/keys/oauth-public.key
|
||||||
chown www-data:www-data storage/app/keys/oauth-*.key
|
|
||||||
|
|
||||||
echo "✓ Claves de Passport verificadas"
|
echo "✓ Claves de Passport verificadas"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user