Support the ongoing development of Laravel.io →
Eloquent Forms Validation
Last updated 2 years ago.
0

Um..I'm not exactly sure if I understand your question or not.

i don't see any validation logic in your code.

The validation class doesn't care whether you pass a value from POST or GET. It just cares about a value.

This should give you an idea.

public function home()
{
	$query = Request::get('q');

    $validator = Validator::make(['q'=>$query], ['q'=>'required']);

    if (!$validator->passes()) {
    	return Redirect::back()->withErrors($validator);
    }

    $complaints = $this->complaint->where('title', 'LIKE', "%$query%");

	return View::make('front.home')->with('complaints', $complaints);
}

Is this what you're looking for?

Last updated 2 years ago.
0

Yes, thanks, i've tried:

$query = Request::get('q');
Validator::make($query); // not working
Validator::make(array('q' => $query)); // working

but it didn't worked because i had to use it like in array and i've used it as a string :)

Last updated 2 years ago.
0

Validator can accept any input at all. I would personally be using Input::get('q') though.

Last updated 2 years ago.
0

grindmodeon said:

Validator can accept any input at all. I would personally be using Input::get('q') though.

What the difference between Request::get('q') and Input::get('q')?

Last updated 2 years ago.
0

heihachi88 said:

grindmodeon said:

Validator can accept any input at all. I would personally be using Input::get('q') though.

What the difference between Request::get('q') and Input::get('q')?

Honestly, I'm not entirely sure. I've always used the Input class and its also used throughout many of the largest Laravel projects so I personally say thats what should be used. As well as its in the documentation while Request is not (afaik).

Last updated 2 years ago.
0

They're the same thing.

If you look at the facades of Request and Input, they're both using Symfony\Component\HttpFoundation\Request.

However, I think it's better to use Input. Most people use Input and even documentation uses Input. I wasn't sure what Request::get is until I looked at the source code.

Last updated 2 years ago.
0

By the way:

Input::all();

returns data in array type? Not a single string?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.