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?
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 :)
Validator can accept any input at all. I would personally be using Input::get('q') though.
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')?
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).
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.
By the way:
Input::all();
returns data in array type? Not a single string?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community