Add stock items, groups and movements at a moving average cost
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Inventory\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use App\Modules\Inventory\Domain\Enums\StockUnit;
|
||||
use Database\Factories\StockItemFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Inventory Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $stock_item_group_id
|
||||
* @property string $name
|
||||
* @property StockUnit $unit
|
||||
* @property string|null $code
|
||||
* @property string|null $supplier
|
||||
* @property int|null $reorder_level_milli
|
||||
* @property int $average_cost_hundredths
|
||||
* @property string|null $image_path
|
||||
* @property string|null $thumbnail_path
|
||||
* @property bool $is_active
|
||||
* @property int|null $balance_milli Selected sum of the movements.
|
||||
*/
|
||||
#[Table('stock_items')]
|
||||
#[Fillable(['stock_item_group_id', 'name', 'unit', 'code', 'supplier', 'reorder_level_milli', 'average_cost_hundredths', 'image_path', 'thumbnail_path', 'is_active'])]
|
||||
#[UseFactory(StockItemFactory::class)]
|
||||
class StockItemModel extends Model
|
||||
{
|
||||
/** @use HasFactory<StockItemFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return BelongsTo<StockItemGroupModel, $this>
|
||||
*/
|
||||
public function group(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StockItemGroupModel::class, 'stock_item_group_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'stock_item_group_id' => 'integer',
|
||||
'unit' => StockUnit::class,
|
||||
'reorder_level_milli' => 'integer',
|
||||
'average_cost_hundredths' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
'balance_milli' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user