71 lines
2 KiB
PHP
71 lines
2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* ProductBundle Model - Verwaltet Set/Kit Produkt-Beziehungen
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class ProductBundle
|
|
*
|
|
* @property int $id
|
|
* @property int $product_id
|
|
* @property int $bundle_product_id
|
|
* @property int $quantity
|
|
* @property int $pos
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property Product $product
|
|
* @property Product $bundleProduct
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle whereProductId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle whereBundleProductId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle whereQuantity($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle wherePos($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ProductBundle whereUpdatedAt($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class ProductBundle extends Model
|
|
{
|
|
protected $table = 'product_bundles';
|
|
|
|
protected $casts = [
|
|
'product_id' => 'int',
|
|
'bundle_product_id' => 'int',
|
|
'quantity' => 'int',
|
|
'pos' => 'int',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'product_id',
|
|
'bundle_product_id',
|
|
'quantity',
|
|
'pos',
|
|
];
|
|
|
|
/**
|
|
* Das Set/Kit-Produkt (Parent)
|
|
*/
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class, 'product_id');
|
|
}
|
|
|
|
/**
|
|
* Das enthaltene Produkt (Child)
|
|
*/
|
|
public function bundleProduct()
|
|
{
|
|
return $this->belongsTo(Product::class, 'bundle_product_id');
|
|
}
|
|
}
|