Laravel 4将刀片输入传递给控制器

I have a project in laravel 4.

In my blade file i have:

<div class="col-sm-12">
            <a href="{{ action('HomeController@getMore') }}" data-limit="12" data-gap="12">Show more </a>
</div>

I want to pass my limit and gap to the controller. In the controller i use Input::get('limit'); but i get back a null. Even Input::all() returns null.

Any tips?

Thank you!

Try this:

<div class="col-sm-12">
        <a href="{{ action('HomeController@getMore', ['dataLimit'=>12, 'dataGap'=>12]) }}" data-limit="12" data-gap="12">Show more </a>

And ensure that your route and controller passed params. Route must be configured with dataLimit and dataGap params, and controller method must accept it.

Input is for forms. If you want to use anchors, you will have to pass parameters to url like this

<a href="/url?limit=12&gap=12" >Show more </a>

This makes them optional to your controller. You just need to get them with request().

$limit = request('limit');
$gap = request('gap');

HTML(VIEW) CODE

  1. Code for a tag <a href="url('submit/Parameters...')">click ok </a>

  2. Form code <form method="POST" action="{{url('submit/Parameters..')}}" method="post"> {{ csrf_field() }} ... </form>

ROUTE CODE

  1. route code with action Route::get('user/{id}', function ($id) { echo "id is : ".$id ; });

  2. route code for controller
    Route::get('user/{id}', 'UserController@show');

    CONTROLLERS CODE
    <?php

namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;

class ShowProfile extends Controller { public function index($id) { echo $id; } }

for more information you see following like https://laravel.com/docs/5.4/controllers and https://laravel.com/docs/5.4/routing