Mikail
Mikail

Reputation: 465

laravel $request->input() doesn't work

I'm trying to retrieve a single input from laravel request

$request->input('username')

But it returns undefined in ajax response, I tried:

$request->only('username')

as well as:

$request->username`

but none of them work, exept for:

$request->all()

which returns the right data object:

Object {
    username: "username",
    password: "password",
    _token: "uKi2r3G1XPiOLhi13da3NC67ssjc1qmeiGWFtQNM"
}

So I need to access single values.

Upvotes: 1

Views: 4346

Answers (3)

Akshay Deshmukh
Akshay Deshmukh

Reputation: 1292

Try this

$request['username'];

Hope this will work.

Upvotes: 1

rupesh
rupesh

Reputation: 277

You can retrieve your data like this make model and make its table

 $posts = Post::orderBy('created_at','desc')->get();

the above code will output the value according to date in descending order. this is the best way

Upvotes: 0

Nour
Nour

Reputation: 1497

use this one

Input::get('username');

or

Request::get('username');

Upvotes: 0

Related Questions