<?php

namespace App\Http\Controllers\Api\User;

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

class LanguageController extends Controller
{
    public function index()
    {
        return Language::where('jobseeker_id', auth()->user()->jobseeker->id)->get();
    }

    public function store(Request $request)
    {
        $data = $request->validate([
            'language_name' => 'required',
            'proficiency_level' => 'required'
        ]);

        $data['jobseeker_id'] = auth()->user()->jobseeker->id;

        return Language::create($data);
    }

    public function destroy($id)
    {
        Language::destroy($id);

        return response()->json(['message'=>'deleted']);
    }
}