php - Is it possible to split query builder in Laravel? -


is possible split queries somehow this?

public function getstatuses($dates) {     $query = db::table('tickets');      if ($dates['from'])         $query = $query->where('from', $dates['from']);      if ($dates['to'])         $query = $query->where('to', $dates['to']);      $query = $query->select('active');      return $query->get()->toarray(); } 

yes, it's possibile. don't reassign same variable or risk messing up:

public function getstatuses($dates) {     $query = db::table('tickets');     if ($dates['from'])         $query->where('from', $dates['from']);     if ($dates['to'])         $query->where('to', $dates['to']);     $query->select('active');     return $query->get()->toarray(); } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -