<?php

namespace App\Models\Ecommerce\Product\Product;

use App\Models\Concerns\HasSchemalessAttributes;
use App\Models\Ecommerce\Product\Product\Concerns\HasPropertiesJson;
use App\Models\Ecommerce\Product\Product\Concerns\ProductFrontEndHelpers;
use App\Models\Ecommerce\Product\Product\Concerns\ProductMedia;
use App\Models\Ecommerce\Product\Product\Concerns\ProductProperties;
use App\Models\Ecommerce\Product\Product\Concerns\ProductRelationships;
use App\Models\Ecommerce\Product\Product\Concerns\ProductScopeQueries;
use App\Models\Ecommerce\Product\Product\Concerns\ProductStates;
use App\Models\Ecommerce\Product\Product\Concerns\ProductStock;
use App\Models\Ecommerce\Product\Product\Concerns\ProductTransformers;
use CyrildeWit\EloquentViewable\Contracts\Viewable;
use CyrildeWit\EloquentViewable\InteractsWithViews;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\Sluggable\HasSlug;

class Product extends Model implements HasMedia, Viewable
{
    /**
     * Has factory (laravel default)
     */
    use HasFactory;

    /**
     * Has Properties Json
     */
    use HasPropertiesJson;

    /**
     * Has Schemaless Attributes (spatie/laravel-schemaless-attributes)
     */
    use HasSchemalessAttributes;

    /**
     * Has Slug (spatie/laravel-sluggable)
     */
    use HasSlug;

    /**
     * Interacts with media (spatie/laravel-medialibrary)
     */
    use InteractsWithMedia;

    /**
     * Interacts with views (cyrildewit/eloquent-viewable)
     */
    use InteractsWithViews;

    /**
     * Product helpers for front end
     */
    use ProductFrontEndHelpers;

    /**
     * Media interactions
     */
    use ProductMedia {
        ProductMedia::registerMediaCollections insteadof InteractsWithMedia;
        ProductMedia::registerMediaConversions insteadof InteractsWithMedia;
    }

    /**
     * Product properties (attributes[EAV])
     */
    use ProductProperties;

    /**
     * Product relationships
     */
    use ProductRelationships;

    /**
     * Product scope queries
     */
    use ProductScopeQueries;

    /**
     * Product states (new, featured, ...)
     */
    use ProductStates;

    /**
     * Products stocks
     */
    use ProductStock;

    /**
     * Interacts with media (whitecube/nova-flexible-content)
     */
    // use HasFlexible;

    /**
     * Product Data Transformers
     */
    use ProductTransformers;

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'id',
        'parent_id',
        'brand_id',
        'name',
        'slug',
        'description',
        'sku',
        'barcode',
        'stock',
        'security_stock',
        'cost_amount',
        'price_amount',
        'old_price_amount',
        'seo_title',
        'seo_description',
        'options',
        'is_visible',
        'colour',
        'size',
        'properties_json',
    ];
}
