Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel Relations transform

        $product = ProductModel::query()->findOrFail($id);
        $product_manufacturer = $product->manufacturer;
        $product_supplier = $product->supplier;
        $product_category = $product->categories->map(function ($category) {
            return new CategoryViewModel($category);
        });
 
PREVIOUS NEXT
Tagged: #laravel #Relations #transform
ADD COMMENT
Topic
Name
6+4 =