Custom column

You can also create your own column in your CRUD, for example number_products, and create an attribute in your model:

    public function getNumberProductsAttribute(){
        return Product::where('category_id', $this->id)->count();
    }

What’s Next