'enroll_table three field fetch to payment form to create payment field in laravel 5.5

enter image description here (figure 1) The above figure 1 image is the snapshot of enroll table, (it belong to the enroll model, enrolls table)

enter image description here (figure 2)

Figure 2 is the page view. My question is when I click pay button, (it belongs to the Payment model, payments table), This Enroll student_id, course_id, course_fee should be transferred to the payment id where need to save these and

enter image description here (figure 3)

figure 3 -> have additional detail padi amount and ...etc.

I Tried in Model it does not support that individually seperate

payment controller details:

   public function index()
{
    //
    // return view('payment.index');

    // $enroll_list = DB::table('enrolls')->groupBy('id')->get();

    $enroll_list = Enroll::all();

    return view('payment.index')->with('enroll_list', $enroll_list);


    // id   enroll_id   student_id  course_fee  paid_amount     paid_date   next_due    last_balance 
}

enroll index page pay button code:

   <td><a href="#" class="btn btn-info btn-xs" role="button" data-toggle="modal" data-target="#payFee"><i class="fa fa-money"> PAY </i></a></td>

How can I transfer the enrol fields to student_id, and batch_id to create a page of the Payment form. Meantime, I should save the payment form in the payments table please help me



Solution 1:[1]

Haa I got the answer for my above posts as follows,

(Figure 2: Student Registration Overview : When I click pay button it should send the student id along with the course id.)

Step 1:

<td><a href="{{ route('payment.fetch', $enroll->id )}}" class="btn btn-info btn-xs" role="button">  <i class="fa fa-money"> PAY </i></a></td>

Now I can retrieve the data from the Enroll ID, then I should take the Data From,

Step 2: the below form on payment creates page (fetch Record)

<form action="{{ route('payment.store',['id'=>$enrolls->id])}}" method="post">
{{ csrf_field() }}
<input name="_method" type="hidden" value="PATCH">

Now I can Call all of the data from the enrol table.

step 3: I need to set the URI/ route On Route:

Route::get('/enroll/{id}', 'PaymentController@fetchEnroll')->name('payment.fetch');

step 4: on Controller:

 public function fetchEnroll($id){

        $user = Auth::user();
        $enrolls = Enroll::findOrFail($id);

        return view('payment.enroll_fetch',compact('enrolls','user'));
    }

Now the view page perfectly working without issues. this answer could be helpful.

pls, give your comments if there are any mistakes. Thank you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M Nuji