How to get data from request in Laravel code example

Example 1: laravel get input from request

public function store(Request $request)
    {
        $name = $request->input('name');

        //
    }

Example 2: ajax laravel get data

$.ajaxSetup({
        headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
    });
    jQuery.ajax({
        url:'/group/create',
        type: 'GET',
        data: {
            name: groupName,
            colour: "red"
        },
        success: function( data ){

            console.log(data);
        },
        error: function (xhr, b, c) {
            console.log("xhr=" + xhr + " b=" + b + " c=" + c);
        }
    });

Example 3: get value mentthod get laravel

Input::get('lastName') ;
//lastName is variable in view

Example 4: laravel add request

$request->all() + ['index' => 'value'];

Example 5: laravel get all request parameters

$request->input('name');
$request->input('user.name'); // fetch from user object

Example 6: laravel get data from request

dd($request->all());
//print an array of the input name and the input value

Tags:

Misc Example