Skip to content

Instantly share code, notes, and snippets.

@robertnicjoo
Created February 7, 2018 02:03
Show Gist options
  • Save robertnicjoo/4f78bec892abd74eeb2a83e532407faa to your computer and use it in GitHub Desktop.
Save robertnicjoo/4f78bec892abd74eeb2a83e532407faa to your computer and use it in GitHub Desktop.
finder function
$post = $request->all(); //Initialize the request
$test = DB::table('products')
->where('subcategory_id','=',$post['subcategory_id']);
if(isset($post['specification_id']) && !(isset($post['brand_id'])))
{
$query = $query->where('subspecification_id','=',$post['specification_id']);
}
elseif(!(isset($post['specification_id'])) && isset($post['brand_id']))
{
$query = $query->where('brand_id','=',$post['brand_id']);
}
else
{
$query = $query->where('subspecification_id','=',$post['specification_id'])
->where('brand_id','=',$post['brand_id']);
}
$test = $test->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment