<?php

namespace App\Models\Concerns;

use Illuminate\Database\Eloquent\Builder;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;

trait HasSchemalessAttributes
{
    /**
     * Add Schemaless Attributes to casts
     */
    public function initializeHasSchemalessAttributes(): void
    {
        $this->casts['options'] = SchemalessAttributes::class;
    }

    /**
     * Scope for Extra attributes
     */
    public function scopeWithExtraAttributes(): Builder
    {
        return $this->options->modelScope();
    }
}
