public function destroy(Request $request, $id)
 {
     $resource = $this->repository->findById($id);
     if (!$resource) {
         return response()->json(['error' => 'Entity not found'], 404);
     }
     $this->manager->setEntity($resource);
     $response = $this->manager->delete();
     if ($response) {
         return response()->json(['success' => 'Entity deleted'], 200);
     }
     return response()->json(['error' => 'Server error. Try Again'], 500);
 }
 public function update($data)
 {
     $response = parent::update($data);
     if ($response instanceof Entity) {
         $response->custom_fields()->delete();
         $custom_fields = [];
         foreach ($this->data['custom_fields'] as $field) {
             $field['field'] = isset($field['name']) ? $field['name'] : '';
             if (!empty($field['field'])) {
                 $field['slug'] = str_slug($field['field']);
                 array_push($custom_fields, new CustomFieldEntity($field));
             }
         }
         $response->custom_fields()->saveMany($custom_fields);
     }
     return $response;
 }
 /**
  * @param Entity $Entity
  * @param Category $Category
  */
 public function __construct(Entity $Entity, Validator $Validator)
 {
     parent::__construct($Entity, $Validator);
 }