insert([ 'product_id' => $data->product_id, 'productable_type' => $this->getProductableType($data->productable_type), 'productable_id' => $data->productable_id, ]); } } catch (Exception $e) { info(['Ignore error', $e->getMessage()]); } } /** * Get productable type */ public function getProductableType(string $name): string { return match ($name) { 'collection' => 'collection', 'App\\Models\\Shop\\Channel' => 'channel', 'category' => 'category', }; } }