<?php

namespace App\Http\Controllers\Api\Job;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\JobRecommendation;

class JobRecommendationController extends Controller
{
    // 🔹 list rekomendasi
    public function index()
    {
        return JobRecommendation::with('job')
            ->where('jobseeker_id', auth()->user()->jobseeker->id)
            ->orderByDesc('match_score')
            ->get();
    }

    // 🔹 mark viewed
    public function markViewed($id)
    {
        $rec = JobRecommendation::findOrFail($id);

        $rec->update([
            'is_viewed' => 1,
            'viewed_at' => now()
        ]);

        return $rec;
    }

    // 🔹 mark applied
    public function markApplied($id)
    {
        $rec = JobRecommendation::findOrFail($id);

        $rec->update([
            'is_applied' => 1
        ]);

        return $rec;
    }
}