<?php

namespace App\Models;

use App\Models\Concerns\BelongsToCompany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class JobPosting extends Model
{
    use BelongsToCompany;

    protected $table = 'job_postings';

    protected $fillable = [
        'company_id',
        'department_id',
        'title',
        'location',
        'employment_type',
        'openings',
        'status',
        'posted_at',
        'description',
    ];

    protected $casts = [
        'posted_at' => 'date',
    ];

    public function department(): BelongsTo
    {
        return $this->belongsTo(Department::class);
    }

    public function applicants(): HasMany
    {
        return $this->hasMany(Applicant::class);
    }
}
