Answers for "filter based on morphToMany"

0

filter based on morphToMany

public function polyTypeOne()
{
    return $this->poly()->where('type','=','1');
}

// usage
$wollies = Woly::with('polyTypeOne')->get();

// pretty much the same as:
$wollies = Woly::with(['poly' => function ($q) {
  $q->where('type', 1);
}])->get();
Posted by: Guest on April-19-2021

Code answers related to "filter based on morphToMany"

Browse Popular Code Answers by Language