My case like this
My code :
if($cover == 'on')
$photo = $image;
$this->product_repository->update($id, [
'photo' =>$photo,
'photo_list'=>json_encode($photo_list)
]);
I want to add condition in array
If $cover != on then it not run this 'photo' => $photo
Seems it need to add conditon in array
How can I do it?
$covervalue you want to call update with eitherphotoandphoto_listor just with thephoto_list? Prepare the array in separate variable adding elements as required, then pass it as a parameter toupdatemethod.