<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;


class ConsultantApplication extends Model
{
  
    public const APPLICATION_PENDING_STATUS = 'pending';
    public const APPLICATION_APPROVED_STATUS = 'approved';
    public const APPLICATION_REJECTED_STATUS = 'rejected';


    protected $fillable = [
        'user_id',
        'company_id',
        'name',
        'email',
        'phone',
        'city',
        'district',
        'position',
        'experience_years',
        'specializations',
        'service_areas',
        'bio',
        'website',
        'instagram',
        'linkedin',
        'application_note',
        'status',
        'terms_accepted',
        'privacy_accepted',
        'rejection_reason',
        'reviewed_at',
        'reviewed_by',
    ];

    protected function casts(): array
    {
        return [
            'specializations' => 'array',
            'service_areas' => 'array',
            'terms_accepted' => 'boolean',
            'privacy_accepted' => 'boolean',
            'experience_years' => 'integer',
            'reviewed_at' => 'datetime',
        ];
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

    /** Kararı veren yönetici (reviewed_by). */
    public function reviewer()
    {
        return $this->belongsTo(User::class, 'reviewed_by');
    }

    public function scopePending($query)
    {
        return $query->where('status', self::APPLICATION_PENDING_STATUS);
    }



}
