amal webdev
amal webdev

Reputation: 35

How to get url value Passing From Laravel Route to php file?

I have an laravel application and also included an php file for a Payment Package,im Passing two url parameters from my laravel route to this Php File .How can i access the passed url parameters in this Php file.

Route::get('payumoneypayment/{courseid}/{userid}', function() {
    include_once(app_path() . '/payu/index.php');  
  });

The route passed from laravel is like this eg http://127.0.0.1:8000/payumoneypayment/1152/44 In my index.php file ,i tried using $userid = $_REQUEST['userid']; but im not getting the request value in php file

Upvotes: 0

Views: 782

Answers (1)

Giacomo M
Giacomo M

Reputation: 4711

you should do something like this:

Route::get('payumoneypayment/{courseid}/{userid}', function($courseid, $userid) {
    return view('payumoneypayment', [
        'courseid' => $courseid,
        'userid' => $userid,
    ]);  
});

After that, in your payumoneypayment view (file payumoneypayment.blade.php):

<?php
include_once(app_path() . '/payu/index.php');

And you will have the variables $courseid and $userid usable in your index.php file.

P.S. its not a good practice use include_once in a blade template file, just use its syntax (@include directive).

Upvotes: 1

Related Questions