user3189734
user3189734

Reputation: 665

Using querystrings with Laravel

I have a URL www.mydomain.com/jobs?applications=2|4|6

I am trying to get the values to work with my Input::get but failing. I have tried using array but this doesn't work. Can anyone advise? I'm unfamiliar with using Laravel with this structure of querystring.

$applicationIDs = Input::get('applications');

$applications = Job::with('users');

if(!empty($applicationIDs)){
     $applications->whereIn('id', $applicationIDs);
}

$applications = $applications->get();

Upvotes: 1

Views: 41

Answers (1)

lukasgeiter
lukasgeiter

Reputation: 152860

Your applications parameter is just a string. Use explode to turn it into an array of ids:

$applicationIDs = explode('|', Input::get('applications'));

Upvotes: 1

Related Questions