Q: How would you handle a multi-field advanced search in a controller? I have a laravel 4 project, and I need to make one module with an advanced search, which is something I'm having trouble wrapping my head around.
Here's my form:
<div class="form-group">
                        {{ Form::open(['route' => 'requests.search']) }}
                        {{ Form::label('status', 'Status:') }}
                        {{ Form::select('status', $statuses, null, ['class' => 'form-control']) }}
                    </div>
                    <!-- Category Form Input -->
                    <div class="form-group">
                        {{ Form::label('category', 'Category:') }}
                        {{ Form::select('category', $categories, null, ['class' => 'form-control']) }}
                    </div>
                    <!-- Teamleader Form Input -->
                    <div class="form-group">
                        {{ Form::label('teamleader', 'Team Leader:') }}
                        {{ Form::select('teamleader', $projectmembers, null, ['class' => 'form-control']) }}
                    </div>
                    <!-- Requestid Form Input -->
                    <div class="form-group">
                        {{ Form::label('requestid', 'Request ID:') }}<br/>
                        <span>Between:</span>
                        {{ Form::text('requestidstart', null, ['class' => 'form-control', 'style' => 'width:100%;']) }}
                        <span>And:</span>
                        {{ Form::text('requestidend', null, ['class' => 'form-control', 'style' => 'width:100%;'])}}
                    </div>
                    <!-- Requestdate Form Input -->
                    <div class="form-group">
                        {{ Form::label('requestdate', 'Request Date:') }}<br/>
                        <span>From:</span>
                        {{ Form::text('requestdatestart', null, ['class' => 'form-control etadatepicker', 'style' => 'width:100%;']) }}
                        <span>To:</span>
                        {{ Form::text('requestdateend', null, ['class' => 'form-control etadatepicker', 'style' => 'width:100%;'])}}
                    </div>
                    <!-- Requestduedate Form Input -->
                    <div class="form-group">
                        {{ Form::label('requestduedate', 'Due Date:') }}<br/>
                        <span>From:</span>
                        {{ Form::text('requestduedatestart', null, ['class' => 'form-control etadatepicker', 'style' => 'width:100%;']) }}
                        <span>To:</span>
                        {{ Form::text('requestduedateend', null, ['class' => 'form-control etadatepicker', 'style' => 'width:100%;'])}}
                    </div>
                    {{ Form::hidden('search', 'advanced') }}
                    {{ Form::submit('Search') }}
                    {{ Form::close() }}<br/>

In my controller, I have the following switch determining whether the user is doing a simple text search or advanced search:             
switch($search)
        {
            case 'text':
                $requests = DataRequest::search($query, ["id", "userid", "subject", "details", "eta", "leader", "member1", "member2", "member3", "member4", "member5", "member6", "status", "time_spent", "date_completed", "category", "comments", "response_method", "created_at", "updated_at"])
                    ->paginate(10);
                return View::make('requests.index', ['requests' => $requests, 'statuses' => $statuses, 'requestresponsetype' => $requestresponsetype, 'projectmembers' => $projectmembers, 'categories' => $categories, 'query' => $query]);
               break;
            case 'advanced':

                break;
            default:
                $requests = DataRequest::orderBy('id', 'DESC')->paginate(10);
                return View::make('requests.index', ['requests' => $requests, 'statuses' => $statuses, 'requestresponsetype' => $requestresponsetype, 'projectmembers' => $projectmembers, 'categories' => $categories, 'query' => $query]);
                break;
        }

Obviously, as I do it for the 'text case, I do know how to use input to query the database for a simple text search.
How would I approach going through each of the fields, utilizing all of their queries, and returning results meeting all of the queries in the fields for the 'advanced' case?
Also, I know that I can do:
                 $requests = DataRequest::where('category', '=', $advancedCategories)
                     ->orWhere('status', '=', $advancedStatus)
                     ->orWhere(...)
                     ->orWhere(...)
                     ->orWhere(...)
                     ->orWhere(...)
                     ->orWhere(...)
                     ->paginate(10);

But then if one of the fields is empty, it will error with: 1054 Unknown column '' in 'where clause' 

A: Having a orWhere condition with an empty value passed from input will not throw any MySQL errors, the condition will just be OR WHERE column = "". However, that is not exactly what you might want as a condition, because it will include all entries that has that column empty, in the result set.
Here's how I would approach it in order to keep it clean and only add the conditions needed:
// Define an array with the names of the input parameters for advanced search
$searchParams = ['category', 'teamleader', 'requestidstart', 'requestidend', 'requestdatestart', 'requestdateend', 'requestduedatestart', 'requestduedateend'];

// Create a blank query for your model on which you can add conditions
$query = DataRequest::query();

// Add only the params that have been passed values from the form as conditions
foreach ($searchParams as $param) {
    if (Input::has($param)) {
        $query->orWhere($param, Input::get($param));
    }
}

// Get your paginated results
$requests = $query->paginate(10);

