<?php

namespace App\Models;

use App\Models\WorkAreaExpertise;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

use Database\Factories\WorkAreaFactory;

class WorkAreas extends Model
{
    use HasFactory;
    use SoftDeletes;

	protected $table = 'work_areas';
    
    protected $fillable = 
    [
        'name',
    	// 'expertise_id',
    ];

    public function expertises() 
    {
        return $this->hasMany(WorkAreaExpertise::class, 'work_area_id', 'id')
            ->join('expertises', 'expertises.id', '=', 'work_areas_expertise.expertise_id');
    }

    /**
     * Create a new factory instance for the model.
     * 
     * @return Factory 
     */
    protected static function newFactory(): Factory
    {
        return WorkAreaFactory::new();
    }
}
