mirror of https://github.com/kcal-app/kcal.git
58 lines
2.2 KiB
PHP
58 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|
use Spatie\Tags\Tag as TagBase;
|
|
|
|
/**
|
|
* App\Models\Tag
|
|
*
|
|
* @property int $id
|
|
* @property array $name
|
|
* @property array $slug
|
|
* @property string|null $type
|
|
* @property int|null $order_column
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property-read array $translations
|
|
* @method static Builder|Tag containing(string $name, $locale = null)
|
|
* @method static \Database\Factories\TagFactory factory(...$parameters)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag newQuery()
|
|
* @method static Builder|Tag ordered(string $direction = 'asc')
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereOrderColumn($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereSlug($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUpdatedAt($value)
|
|
* @method static Builder|Tag withType(?string $type = null)
|
|
* @mixin \Eloquent
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Food[] $foods
|
|
* @property-read int|null $foods_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Recipe[] $recipes
|
|
* @property-read int|null $recipes_count
|
|
*/
|
|
final class Tag extends TagBase
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Get all foods related to this tag.
|
|
*/
|
|
public function foods(): MorphToMany {
|
|
return $this->morphedByMany(Food::class, 'taggable');
|
|
}
|
|
|
|
/**
|
|
* Get all recipes related to this tag.
|
|
*/
|
|
public function recipes(): MorphToMany {
|
|
return $this->morphedByMany(Recipe::class, 'taggable');
|
|
}
|
|
}
|