first commit
This commit is contained in:
47
Models/PriceList.php
Normal file
47
Models/PriceList.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace koneko\VuexyPos\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Koneko\VuexyStoreManager\Models\Currency;
|
||||
|
||||
class PriceList extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'price_lists';
|
||||
protected $primaryKey = 'id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'smallint';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'type',
|
||||
'c_currency',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'type' => 'integer',
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relación con los precios de productos.
|
||||
*/
|
||||
public function productPrices(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProductPrice::class, 'pricelist_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relación con la moneda de la lista de precios.
|
||||
*/
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class, 'c_currency', 'c_currency');
|
||||
}
|
||||
}
|
61
Models/ProductPrice.php
Normal file
61
Models/ProductPrice.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Koneko\VuexyWarehouse\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ProductPrice extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'product_prices';
|
||||
protected $primaryKey = 'id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'mediumint';
|
||||
|
||||
protected $fillable = [
|
||||
'product_id',
|
||||
'pricelist_id',
|
||||
'unit_price',
|
||||
'discount_percentage',
|
||||
'final_price',
|
||||
'taxes_transferred',
|
||||
'taxes_retained',
|
||||
'total_amount',
|
||||
'valid_from',
|
||||
'valid_to',
|
||||
'min_quantity',
|
||||
'max_quantity',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'unit_price' => 'decimal:6',
|
||||
'discount_percentage' => 'decimal:2',
|
||||
'final_price' => 'decimal:6',
|
||||
'taxes_transferred' => 'decimal:6',
|
||||
'taxes_retained' => 'decimal:6',
|
||||
'total_amount' => 'decimal:6',
|
||||
'valid_from' => 'date',
|
||||
'valid_to' => 'date',
|
||||
'min_quantity' => 'integer',
|
||||
'max_quantity' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relación con el producto.
|
||||
*/
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relación con la lista de precios.
|
||||
*/
|
||||
public function priceList(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PriceList::class, 'pricelist_id');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user