48 lines
1 KiB
PHP
48 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
class ProductWoodOrigin extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\ProductWoodOriginFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'product_id',
|
|
'wood_species',
|
|
'origin_country',
|
|
'origin_region',
|
|
'harvest_year',
|
|
'forest_operator',
|
|
'sustainability_certificate',
|
|
'eudr_reference_id',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'harvest_year' => 'integer',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Gehört zu einem Produkt.
|
|
*/
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
/**
|
|
* EUDR-Dokumente (polymorphe Beziehung via Media).
|
|
*/
|
|
public function media(): MorphMany
|
|
{
|
|
return $this->morphMany(Media::class, 'model');
|
|
}
|
|
}
|