Deploy / deploy (push) Successful in 26s
- Add SKU and GTIN fields to product variant repeater - Render EAN/UPC barcode live from GTIN input (picqer/php-barcode-generator) - Pull variant price from Shopify API instead of defaulting to 0 - Sync sku/gtin through EditProduct and CreateProduct save logic Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
832 B
PHP
38 lines
832 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 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);
|
|
}
|
|
} |