How to check the columns of another table and get its values ​​in the other table


i am struggling over this problem Shortly, i have payments page. Admin selects the user and course, then he should select course_type,which gets value from courses table's three columns(cost_group, cost_minigroup, cost_individual,one of them). If course_type is selected, the cost of course must be inserted into payments table(inside course_cost column). So what i have done


payments{ id,student_id, course_id, course_cost}
courses { id, name,cost_group,cost_minigroup,cost_individual }

My CourseController.php

>  public function get($id){
>         $course = Course::findOrFail($id);
>         return response()->json($course);
>     }

Here is my form.blade.php

<div class="ui selection dropdown">
  <input type="hidden" name="course_">
      <i class="dropdown icon"></i>
       <div class="default text">Course type</div>
   <div class="menu">
       <div class="item" data-value="course_group">Group</div>
       <div class="item" data-value="course_minigroup">Mini Group</div>
       <div class="item" data-value="individual">Individual</div>

My PaymentsController

 public function store(){
      $payment = new Payment;
      $payment->student_id = Input::get('student_id');
      $payment->course_id = Input::get('course_id');
      $payment->course_cost = Input::get('course_cost');
      return redirect('payment');

So here is problem how to get this course_cost value out of three columns of courses table. If you know how to solve or any method or advice would be great. Thank you in advance guys.

You should better get the values by js.and in your field(drop-down) there should be this code instead

<div class="menu">
   <div class="item" data-value="{{$data['course_group']}}">Your call1</div>
   <div class="item" data-value="{{$data['course_minigroup']}}">Your call2</div>
   <div class="item" data-value="{{$data['course_individual']}}">Your call3</div>

And then You should insert some controller code

$payment->course_cost = Input::get('course_val');

And try this on your .js file

alert('Your alert')