Hello,
Looks like you are using explode on an integer :
$this->sub_cat = explode(",", $this->productFilter->sub_category_id);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I have 3 tables like that:
sub_category(id , sub_category_name) product_filters(id, filter_name , sub_category_id) filter_value(id, filter_value_name, product_filter_id)
When i choose a subCategory i need to show the related filter_name , and filter_value_name, The sub_category_id in product_filters is varchar , in in database it will be like that: sub_category_id : 1,2,3 And i have the relations in models, I have this code:
public $sub;
public $productFilter;
public $sub_cat;
public function mount(Subcategory $sub, ProductFilter $productFilter)
{
$this->sub = $sub;
$this->productFilter = $productFilter;
$this->sub_cat = explode(",", $this->productFilter->sub_category_id);
}
public function getFilter()
{
$filters = ProductFilter::join('product_filter_values', 'product_filters.id', '=',
'product_filter_values.product_filter_id')
->join('sub_categories', 'sub_categories.id', '=', 'product_filters.sub_category_id')
->select('product_filters.filter_name', 'product_filter_values.filter_value')
->where('sub_categories.id', $this->sub->id)
->get()
->groupBy('filter_name')
->map(function ($values) {
return $values->pluck('filter_value');
});
return $filters;
}
But there is no result tried dd($this->sub_cat) but i got 0
Please or to participate in this conversation.