File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -153,11 +153,12 @@ public function deleteProductAttribute($productAttributeId)
153
153
*/
154
154
public function destroy (Product $ product )
155
155
{
156
+ $ deletedData = $ this ->productRepository ->delete ($ product ->id );
156
157
$ path = 'products/ ' .$ product ->image ;
157
158
if (Storage::disk ('public ' )->exists ($ path )) {
158
159
Storage::disk ('public ' )->delete ($ path );
159
- }
160
- return $ this -> productRepository -> delete ( $ product -> id ) ;
160
+ }
161
+ return $ deletedData ;
161
162
}
162
163
163
164
public function bulk_delete (Request $ request ){
Original file line number Diff line number Diff line change @@ -125,15 +125,17 @@ public function delete(int $id){
125
125
public function bulk_delete ($ selected_data )
126
126
{
127
127
$ this ->flush ($ this ->CACHE_KEY );
128
+ DB ::beginTransaction ();
128
129
foreach ($ selected_data as $ product ) {
129
130
$ found = $ this ->findById ($ product ['id ' ]);
130
131
$ path = 'products/ ' .$ found ['image ' ];
132
+
131
133
if (Storage::disk ('public ' )->exists ($ path )) {
132
134
Storage::disk ('public ' )->delete ($ path );
133
135
}
134
- DB ::beginTransaction ();
135
136
$ found ->delete ();
136
- DB ::commit ();
137
137
}
138
+ DB ::commit ();
139
+ // success
138
140
}
139
141
}
You can’t perform that action at this time.
0 commit comments