Deploy / deploy (push) Successful in 15s
- Add version + product_id to recipes table (migration) - Recipe select shows version label (e.g. "Kurkuma v2") - Creating recipe from product page pre-fills product name, auto-increments version - Recipe ingredient summary shown read-only below the select - Remove package_content field (redundant with recipe ingredients) - Pull product description from Shopify body_html on import - Update existing products with empty description on re-import Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
952 B
PHP
43 lines
952 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Product extends Model
|
|
{
|
|
protected $fillable = ['title', 'description', 'images', 'package_content', 'recipes_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);
|
|
}
|
|
} |