64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class ProductIngredient
|
|
*
|
|
* @property int $id
|
|
* @property int $product_id
|
|
* @property int $ingredient_id
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property Ingredient $ingredient
|
|
* @property Product $product
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereIngredientId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereProductId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereUpdatedAt($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class ProductIngredient extends Model
|
|
{
|
|
protected $table = 'product_ingredients';
|
|
|
|
protected $casts = [
|
|
'product_id' => 'int',
|
|
'ingredient_id' => 'int',
|
|
'pos' => 'int',
|
|
'gram' => 'decimal:3',
|
|
'factor' => 'decimal:2',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'product_id',
|
|
'ingredient_id',
|
|
'pos',
|
|
'gram',
|
|
'factor',
|
|
'recipe_type',
|
|
];
|
|
|
|
public function ingredient()
|
|
{
|
|
return $this->belongsTo(Ingredient::class, 'ingredient_id');
|
|
}
|
|
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class, 'product_id');
|
|
}
|
|
}
|