feat: add ticket fields to Product and ProductVariant models, requests, and resources
This commit is contained in:
parent
0e9f7faaf1
commit
cababe1a43
|
|
@ -18,6 +18,9 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
'stock_reservado',
|
'stock_reservado',
|
||||||
'stock',
|
'stock',
|
||||||
'is_placeholder',
|
'is_placeholder',
|
||||||
|
'has_tickets',
|
||||||
|
'minimum_use_date',
|
||||||
|
'maximum_use_date',
|
||||||
])]
|
])]
|
||||||
class ProductVariant extends Model
|
class ProductVariant extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -126,6 +129,9 @@ class ProductVariant extends Model
|
||||||
'stock_real' => 'integer',
|
'stock_real' => 'integer',
|
||||||
'stock_reservado' => 'integer',
|
'stock_reservado' => 'integer',
|
||||||
'is_placeholder' => 'boolean',
|
'is_placeholder' => 'boolean',
|
||||||
|
'has_tickets' => 'boolean',
|
||||||
|
'minimum_use_date' => 'datetime',
|
||||||
|
'maximum_use_date' => 'datetime',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ class StoreProductVariantRequest extends FormRequest
|
||||||
'definitions.*.value' => ['nullable', 'string'],
|
'definitions.*.value' => ['nullable', 'string'],
|
||||||
'images' => ['sometimes', 'nullable', 'array'],
|
'images' => ['sometimes', 'nullable', 'array'],
|
||||||
'images.*' => ['required', new ImageOrBase64Rule()],
|
'images.*' => ['required', new ImageOrBase64Rule()],
|
||||||
|
'has_tickets' => ['boolean'],
|
||||||
|
'minimum_use_date' => ['nullable', 'date'],
|
||||||
|
'maximum_use_date' => ['nullable', 'date', 'after_or_equal:minimum_use_date'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ class UpdateProductVariantRequest extends FormRequest
|
||||||
'definitions.*.value' => ['nullable', 'string'],
|
'definitions.*.value' => ['nullable', 'string'],
|
||||||
'images' => ['sometimes', 'nullable', 'array'],
|
'images' => ['sometimes', 'nullable', 'array'],
|
||||||
'images.*' => ['required', new ImageOrBase64Rule()],
|
'images.*' => ['required', new ImageOrBase64Rule()],
|
||||||
|
'has_tickets' => ['boolean'],
|
||||||
|
'minimum_use_date' => ['nullable', 'date'],
|
||||||
|
'maximum_use_date' => ['nullable', 'date', 'after_or_equal:minimum_use_date'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class ProductResource extends JsonResource
|
||||||
'precio' => $this->precio,
|
'precio' => $this->precio,
|
||||||
'category' => $this->whenLoaded('category', fn () => $this->category?->nombre),
|
'category' => $this->whenLoaded('category', fn () => $this->category?->nombre),
|
||||||
'brand' => $this->whenLoaded('brand', fn () => $this->brand?->nombre),
|
'brand' => $this->whenLoaded('brand', fn () => $this->brand?->nombre),
|
||||||
|
|
||||||
'images' => $this->whenLoaded('attachments', fn () => $this->attachments
|
'images' => $this->whenLoaded('attachments', fn () => $this->attachments
|
||||||
->map(fn ($attachment) => $attachment->getTemporaryUrl(1440))
|
->map(fn ($attachment) => $attachment->getTemporaryUrl(1440))
|
||||||
->values()
|
->values()
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ class ProductVariantResource extends JsonResource
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'cantidad_maxima' => $this->stock_tecnico,
|
'cantidad_maxima' => $this->stock_tecnico,
|
||||||
|
'has_tickets' => $this->has_tickets,
|
||||||
|
'minimum_use_date' => $this->minimum_use_date,
|
||||||
|
'maximum_use_date' => $this->maximum_use_date,
|
||||||
'product' => ProductResource::make($this->whenLoaded('product')),
|
'product' => ProductResource::make($this->whenLoaded('product')),
|
||||||
'definitions' => $this->whenLoaded(
|
'definitions' => $this->whenLoaded(
|
||||||
'definitions',
|
'definitions',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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('productos', function (Blueprint $table) {
|
||||||
|
$table->boolean('has_tickets')->default(false);
|
||||||
|
$table->dateTime('minimum_use_date')->nullable();
|
||||||
|
$table->dateTime('maximum_use_date')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('productos', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['has_tickets', 'minimum_use_date', 'maximum_use_date']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?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('productos', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['has_tickets', 'minimum_use_date', 'maximum_use_date']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('productos_variantes', function (Blueprint $table) {
|
||||||
|
$table->boolean('has_tickets')->default(false);
|
||||||
|
$table->dateTime('minimum_use_date')->nullable();
|
||||||
|
$table->dateTime('maximum_use_date')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('productos', function (Blueprint $table) {
|
||||||
|
$table->boolean('has_tickets')->default(false);
|
||||||
|
$table->dateTime('minimum_use_date')->nullable();
|
||||||
|
$table->dateTime('maximum_use_date')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('productos_variantes', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['has_tickets', 'minimum_use_date', 'maximum_use_date']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -11,4 +11,4 @@ require __DIR__.'/../app/Domains/Purchase/routes/api.php';
|
||||||
require __DIR__.'/../app/Domains/Tenant/routes/api.php';
|
require __DIR__.'/../app/Domains/Tenant/routes/api.php';
|
||||||
require __DIR__.'/../app/Domains/Integration/routes/api.php';
|
require __DIR__.'/../app/Domains/Integration/routes/api.php';
|
||||||
require __DIR__.'/../app/Domains/Menu/routes/api.php';
|
require __DIR__.'/../app/Domains/Menu/routes/api.php';
|
||||||
require __DIR__.'/../app/Domains/Product/routes/api.php';
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue