mardi 25 avril 2017

How to check another table's columns and get their values to 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

Tables:

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="field">    
   <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>
                         </div>
                     </div>
                 </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('cost');
      $payment->save();

        return redirect('payment');
        }

so here is problem how to get this cost value in paymentscontroller. If you know how to solve or any method or advice would be great. Thank you in advance guys.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire