<?php

namespace App\Models;

use App\Traits\HasCategories;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Skill extends Model
{
    use HasFactory;
    use HasCategories;

    protected $guarded = [];

    public function engineers()
    {
        return $this->morphedByMany(Engineer::class, 'skillable');
    }

    public function firms()
    {
        return $this->morphedByMany(Firm::class, 'skillable');
    }

    public function portofolioProjects()
    {
        return $this->morphedByMany(PortfolioProject::class, 'skillable');
    }

    public function services()
    {
        return $this->morphedByMany(Service::class, 'skillable');
    }

    public function projects()
    {
        return $this->morphedByMany(Project::class, 'skillable');
    }

    public function verify()
    {
        $this->update([
            "verified" => true,
        ]);
    }

    public function getVerifiedSkills()
    {
        return Skill::all()->where('verified', true);
    }
}
