ldc-startcoq/app/Models/Keyword.php

60 lines
1.3 KiB
PHP
Raw Normal View History

2023-02-22 11:51:36 +01:00
<?php
namespace App\Models;
use App\Enums\KeywordCategoryEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property string $label
* @property \App\Enums\KeywordCategoryEnum $keyword_cat
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
2023-09-08 16:02:21 +02:00
*
* * RELATIONSHIPS
* @property-read \Illuminate\Database\Eloquent\Collection<\App\Models\Product> $products
* @property-read \Illuminate\Database\Eloquent\Collection<\App\Models\Keyword> $keywordables
2023-02-22 11:51:36 +01:00
*/
class Keyword extends Model
{
/**
* @var array
*/
protected $fillable = [
'label',
'keyword_cat',
'created_at',
'updated_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'keyword_cat' => KeywordCategoryEnum::class
];
2023-09-08 16:02:21 +02:00
// * RELATIONSHIPS
2023-02-22 11:51:36 +01:00
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function keywordables()
{
return $this->hasMany(Keywordable::class);
2023-02-22 11:51:36 +01:00
}
2023-06-21 10:24:56 +00:00
/**
* MorphToMany products relation.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function products()
{
return $this->morphToMany(Product::class, 'keywordable');
}
2023-02-22 11:51:36 +01:00
}