<?php

namespace App\Http\Controllers\Ajax;

use App\Http\Controllers\Exam\ExamController;
use App\MediumKeywordMediumAbstract;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class HandleKeywordRelations extends Controller
{

    public function addKeyword(Request $request) {

        $status = 'success';

        $mediumKeywordMediumAbstract = new MediumKeywordMediumAbstract();
        $mediumKeywordMediumAbstract->t_medium_abstract_id = $request->mediumAbstractId;
        $mediumKeywordMediumAbstract->t_medium_keyword_id = $request->keyword;
        $mediumKeywordMediumAbstract->save();

        // return data to redirect user via JavaScript
        $response = array(
            'status' => $status,
            'redirectUrl' => '/',
        );

        return response()->json($response);
    }
}
