cas de non association de tag

This commit is contained in:
Olivier Legat 2021-04-12 17:27:16 +02:00
parent 2fbca40f06
commit 4e84e7e943

View file

@ -255,18 +255,20 @@ class ProductsController extends Controller
}
//tags associés
$arTagIds = array();
foreach($tags as $tag) {
$oTag = json_decode($tag);
if(empty($oTag->id)) {
//we need a new tag
$arTagIds[] = $this->storeTag($oTag);
} else {
$arTagIds[] = $oTag->id;
if(count($tags)) {
$arTagIds = array();
foreach($tags as $tag) {
$oTag = json_decode($tag);
if(empty($oTag->id)) {
//we need a new tag
$arTagIds[] = $this->storeTag($oTag);
} else {
$arTagIds[] = $oTag->id;
}
}
//prise en charge de la liaison avec les produits
$product->tags()->sync($arTagIds);
}
//prise en charge de la liaison avec les produits
$product->tags()->sync($arTagIds);
//produits associés
if(!empty($request->prods)) {