I have the following attitude towards people [/ p>
class Broker extends Eloquent{
public function configurable(){
return $this->morphTo();
}
}
class ProductConfiguration extends Eloquent{
public function productConfigurations()
{
return $this->morphMany('Excel\Products\ProductConfiguration','configurable');
}
}
I can easily find all ProductConfigurations owned by the Broker by doing this:
$broker = Broker::find($id);
$productConfigurations = $broker->productConfigurations;
I do not understand how to define the conditions for ProductConfigurations, so if my ProductConfiguration has a field type, something like:
$broker = Broker::find($id);
$productConfigurations = $broker->productConfigurations->where('type' = 'reg');
Checking the documentation I can’t determine exactly how to do this.
source
share