Pages

laravel : Accessing The Request from URL using get method


To obtain an instance of the current HTTP request via dependency injection,you should type-hint the Illuminate\Http\Request class on your controller method.

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class CategoryController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index(Request $request)
    {
  echo "==>".   $name = $request->input('name');
    }
}

web.php

Route::get('/category', 'CategoryController@index')->name('category');

http://127.0.0.1:8000/category?name=test

No comments:

Post a Comment

Popular Posts