Created
October 23, 2022 11:04
-
-
Save aklimaruhina/64905246a77238cf12c24399d3bab528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when you need to use map function while imploading | |
function implodeProduct($product){ | |
$multiplied = $product->stocks->map(function ($item, $key) { | |
return $item->size .' = '.$item->qty ; | |
}); | |
return $multiplied->implode(', <br>'); | |
} | |
and model | |
// each product might have many product | |
public function stocks() | |
{ | |
return $this->hasMany(Stock::class,'product_id'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment