<?php

namespace App\Domains\Tenant\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class SocialMedia extends Model
{
    protected $table = 'social_media';

    protected $fillable = [
        'code',
        'icon',
        'name',
    ];

    /**
     * @return BelongsToMany<Tenant, $this>
     */
    public function tenants(): BelongsToMany
    {
        return $this->belongsToMany(
            Tenant::class,
            'tenant_social_media',
            'social_media_code',
            'tenant_code',
            'code',
            'codigo'
        )
            ->withPivot(['url', 'orden'])
            ->withTimestamps()
            ->orderByPivot('orden');
    }
}
