首页 > 解决方案 > explode column from database

问题描述

Hi every I need to get product from the database and explode it in one line of code So I can get product data and get product_properties as an array together

    $Product = Product::find(33);
    $properties = explode(",", ($Product ->product_properties));

标签: phplaraveleloquent

解决方案


You can achieve it doing:

    $properties = explode(",", (Product::find(33)->product_properties));

But this is poor in readability compared with your first approach.


推荐阅读