<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Tag extends Model
{
    use SoftDeletes;
    /**
     * Don't auto-apply mass assignment protection.
     *
     * @var array
     */
    protected $guarded = [];

    // explicitly define tables
    protected $table = 'tags';

    protected $fillable = [
        'text'
    ];

    public function scopeAlphaordered($query)
    {
        return $query->orderBy('text', 'asc')->get();
    }

    // clipart tags
    public function clipart()
    {
        return $this->belongsToMany('App\Models\Graphics\Clipart', 'clipart_tags', 'clipart_id', 'tag_id');
    }

    // board tags
    public function boards()
    {
        return $this->belongsToMany('App\Models\Boards\Board', 'boards_tags', 'board_id', 'tag_id');
    }
}
