Files
Malek TellissiandClaude Sonnet 4.6 5c034ec895
Deploy / deploy (push) Successful in 14s
Add lot_prefix to products; compose LOT number from prefix + date suffix
Products now have a configurable lot_prefix (e.g. "112"). In the batch form
the prefix is shown read-only next to the suffix input (JJMMTT), and the full
lot_number (e.g. "112-260912") is composed automatically and stored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-12 20:35:37 +02:00

43 lines
988 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $fillable = ['title', 'lot_prefix', 'description', 'images', 'package_content', 'recipes_id', 'shopify_product_id'];
protected $casts = [
'images' => 'array',
];
public function recipe()
{
return $this->belongsTo(Recipe::class, 'recipes_id');
}
public function recipeVersions()
{
return $this->hasMany(Recipe::class)->orderByDesc('version');
}
public function sizes()
{
return $this->belongsToMany(Packing::class, 'products_sizes')
->withPivot('price', 'description', 'sku', 'gtin')
->withTimestamps();
}
public function inventories()
{
return $this->hasMany(ProductInventory::class);
}
public function batches()
{
return $this->hasMany(Batch::class);
}
}