HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/Properties/Models/PropertyKey.php
<?php


namespace App\Properties\Models;


use App\Categories\Models\Category;
use App\Properties\Resources\StateTrackingTrait;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Komma\KMS\Core\AbstractTranslatableModel;
use Komma\KMS\Core\Attributes\Models\Traits\HasThumbnailInterface;
use Komma\KMS\Core\Attributes\Models\Traits\HasThumbnailTrait;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Komma\KMS\Core\Entities\DisplayNameInterface;
use Komma\KMS\Core\Entities\DisplayNameTrait;

/**
 * App\Properties\Models\PropertyKey
 *
 * @property int $id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection|Category[] $categoriesThatHaveThisPropertyKeyAsRequired
 * @property-read int|null $categories_that_have_this_property_key_as_required_count
 * @property-read mixed $state
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Properties\Models\Property[] $properties
 * @property-read int|null $properties_count
 * @property-read \App\Properties\Models\PropertyKeyTranslation|null $translation
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Properties\Models\PropertyKeyTranslation[] $translations
 * @property-read int|null $translations_count
 * @method static \Illuminate\Database\Eloquent\Builder|PropertyKey newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|PropertyKey newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|PropertyKey query()
 * @method static \Illuminate\Database\Eloquent\Builder|PropertyKey whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|PropertyKey whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|PropertyKey whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class PropertyKey extends AbstractTranslatableModel implements HasThumbnailInterface, DisplayNameInterface, PropertyKeyValueInterface
{
    use HasThumbnailTrait;
    use DisplayNameTrait;
    use StateTrackingTrait;

    public function categoriesThatHaveThisPropertyKeyAsRequired() {
        return $this->belongsToMany(Category::class);
    }

    /**
     * Gets the translation models for this model
     *
     * @return HasMany that resolves to AbstractTranslationModel instances
     */
    public function translations(): HasMany
    {
        return $this->hasMany(PropertyKeyTranslation::class);
    }

    function properties():HasMany
    {
        return $this->HasMany(Property::class);
    }

    function getDisplayName(): ?string
    {
        return $this->translation->name ?? '';
    }
}